Skip to content

Commit

Permalink
#1733: Should be possible to attach a ProgId directly to a component,…
Browse files Browse the repository at this point in the history
… without a COM registration
  • Loading branch information
oleg-shilo committed Jan 22, 2025
1 parent c9d93bb commit bb6ce1c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
24 changes: 23 additions & 1 deletion Source/src/WixSharp/ComRegistration.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System;
using System.Diagnostics;
using System.Linq;
using System.Xml.Linq;
using WixSharp.CommonTasks;

namespace WixSharp
{
Expand Down Expand Up @@ -507,7 +509,27 @@ public void Process(ProcessingContext context)
_ = ProgIds.ForEach(progId => progId.Process(progIdContext));
}

context.XParent.Add(element);
if (context.XParent.LocalName() == "Class" || context.XParent.LocalName() == "ProgId")
{
context.XParent.Add(element);
}
else
{
var findComponent = context.XParent.FindFirst("Component");

if (findComponent != null)
{
findComponent.Add(element);
}
else
{
XElement newComponent = this.WrapInNewParentComponent(element);
context.XParent.Add(newComponent);

MapComponentToFeatures(newComponent.Attr("Id"), ActualFeatures, context);
}
}

}
}

Expand Down
7 changes: 7 additions & 0 deletions Source/src/WixSharp/CommonTasks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1612,6 +1612,13 @@ static public XElement SetConfigAttribute(this XElement config, string elementPa
return config;
}

static public XElement WrapInNewParentComponent(this WixEntity entity, XElement element)
{
XElement newComponent = entity.CreateParentComponent();
newComponent.Add(element);
return newComponent;
}

/// <summary>
/// Creates the parent component for a given <see cref="WixSharp.WixEntity"/>.
/// </summary>
Expand Down

0 comments on commit bb6ce1c

Please sign in to comment.