Skip to content

Commit daa1f37

Browse files
committed
- Issue #137: Add custom attribute to Bundle project (Bootstrapper)
1 parent fd59c58 commit daa1f37

3 files changed

Lines changed: 21 additions & 7 deletions

File tree

Source/src/WixSharp.Samples/Wix# Samples/Bootstrapper/WixBootstrapper/setup.cs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,17 @@ static public void Main(string[] args)
4545

4646
//msiOnlinePackage, //just a demo sample
4747

48-
new MsiPackage(crtMsi) { DisplayInternalUI = true, Visible = true, MsiProperties = "PACKAGE_PROPERTY=[BundleVariable]" },
49-
new MsiPackage(productMsi) { DisplayInternalUI = true, Payloads = new[] { "script.dll".ToPayload() } });
48+
new MsiPackage(crtMsi)
49+
{
50+
DisplayInternalUI = true,
51+
Visible = true,
52+
MsiProperties = "PACKAGE_PROPERTY=[BundleVariable]"
53+
},
54+
new MsiPackage(productMsi)
55+
{
56+
DisplayInternalUI = true,
57+
Payloads = new[] { "script.dll".ToPayload() }
58+
});
5059

5160
bootstrapper.AboutUrl = "https://github.com/oleg-shilo/wixsharp/";
5261
bootstrapper.IconFile = "app_icon.ico";
@@ -67,11 +76,13 @@ static public void Main(string[] args)
6776
// bootstrapper.Application.LicensePath = null; //HyperlinkLicense app with no license
6877

6978
bootstrapper.Application.AttributesDefinition = "ShowVersion=yes; ShowFilesInUse=yes";
70-
// bootstrapper.Application.Bo
7179
bootstrapper.Include(WixExtension.Util);
7280

81+
bootstrapper.IncludeWixExtension(@"WixDependencyExtension.dll", "dep", "http://schemas.microsoft.com/wix/DependencyExtension");
82+
bootstrapper.AttributesDefinition = "{dep}ProviderKey=01234567-8901-2345-6789-012345678901";
83+
7384
// The code below sets WiX variables 'Netfx4FullVersion' and 'AdobeInstalled'. Note it has no affect on
74-
//the runtime behavior and 'FileSearch' and "RegistrySearch" are only provided as an example.
85+
//the runtime behaviour and 'FileSearch' and "RegistrySearch" are only provided as an example.
7586
bootstrapper.AddWixFragment("Wix/Bundle",
7687
new UtilRegistrySearch
7788
{

Source/src/WixSharp/AutoElements.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ static void InjectPlatformAttributes(XDocument doc)
421421
}
422422
}
423423

424-
static void ExpandCustomAttributes(XDocument doc, Project project)
424+
internal static void ExpandCustomAttributes(XDocument doc, WixProject project)
425425
{
426426
foreach (XAttribute instructionAttr in doc.Root.Descendants().Select(x => x.Attribute("WixSharpCustomAttributes")).Where(x => x != null))
427427
{
@@ -438,9 +438,9 @@ static void ExpandCustomAttributes(XDocument doc, Project project)
438438
}
439439
}
440440

441-
static Func<XElement, string, Project, bool> ExpandCustomAttribute = DefaultExpandCustomAttribute;
441+
static Func<XElement, string, WixProject, bool> ExpandCustomAttribute = DefaultExpandCustomAttribute;
442442

443-
static bool DefaultExpandCustomAttribute(XElement source, string item, Project project)
443+
static bool DefaultExpandCustomAttribute(XElement source, string item, WixProject project)
444444
{
445445
var attrParts = item.Split('=');
446446
// {dep}ProductKey=12345 vs Component:{dep}ProductKey=12345

Source/src/WixSharp/Compiler.Bootstrapper.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,9 @@ public static string BuildWxs(Bundle project)
275275
AutoElements.NormalizeFilePaths(doc, project.SourceBaseDir, EmitRelativePaths);
276276

277277
project.InvokeWixSourceGenerated(doc);
278+
279+
AutoElements.ExpandCustomAttributes(doc, project);
280+
278281
if (WixSourceGenerated != null)
279282
WixSourceGenerated(doc);
280283

0 commit comments

Comments
 (0)