diff options
author | Rob Mensching <rob@firegiant.com> | 2022-03-15 15:04:51 -0700 |
---|---|---|
committer | Rob Mensching <rob@firegiant.com> | 2022-03-15 15:51:57 -0700 |
commit | 04b84e3b55402707497dab249a300f9cf1d216c7 (patch) | |
tree | 9b27a228d82ab5031a21735e3e22a2068d2dd37b | |
parent | 7558404a7e853aa98344e52ecffd2bf92d0b0afd (diff) | |
download | wix-04b84e3b55402707497dab249a300f9cf1d216c7.tar.gz wix-04b84e3b55402707497dab249a300f9cf1d216c7.tar.bz2 wix-04b84e3b55402707497dab249a300f9cf1d216c7.zip |
Normalize related bundle ids
Fixes 6008
-rw-r--r-- | src/wix/WixToolset.Core.Burn/Bind/BindBundleCommand.cs | 85 | ||||
-rw-r--r-- | src/wix/test/WixToolsetTest.CoreIntegration/BundleFixture.cs | 4 | ||||
-rw-r--r-- | src/wix/test/WixToolsetTest.CoreIntegration/BundleManifestFixture.cs | 43 | ||||
-rw-r--r-- | src/wix/test/WixToolsetTest.CoreIntegration/TestData/BundleLocalized/BundleWithInvalidUpgradeCode.wxl (renamed from src/wix/test/WixToolsetTest.CoreIntegration/TestData/BundleWithInvalid/BundleWithInvalidUpgradeCode.wxl) | 2 | ||||
-rw-r--r-- | src/wix/test/WixToolsetTest.CoreIntegration/TestData/BundleLocalized/BundleWithLocalizedUpgradeCode.wxs (renamed from src/wix/test/WixToolsetTest.CoreIntegration/TestData/BundleWithInvalid/BundleWithInvalidUpgradeCode.wxs) | 2 | ||||
-rw-r--r-- | src/wix/test/WixToolsetTest.CoreIntegration/TestData/BundleLocalized/BundleWithValidUpgradeCode.wxl | 3 |
6 files changed, 103 insertions, 36 deletions
diff --git a/src/wix/WixToolset.Core.Burn/Bind/BindBundleCommand.cs b/src/wix/WixToolset.Core.Burn/Bind/BindBundleCommand.cs index eb822fba..16e63492 100644 --- a/src/wix/WixToolset.Core.Burn/Bind/BindBundleCommand.cs +++ b/src/wix/WixToolset.Core.Burn/Bind/BindBundleCommand.cs | |||
@@ -102,10 +102,10 @@ namespace WixToolset.Core.Burn | |||
102 | 102 | ||
103 | bundleSymbol.ProviderKey = bundleSymbol.BundleId = Guid.NewGuid().ToString("B").ToUpperInvariant(); | 103 | bundleSymbol.ProviderKey = bundleSymbol.BundleId = Guid.NewGuid().ToString("B").ToUpperInvariant(); |
104 | 104 | ||
105 | bundleSymbol.UpgradeCode = this.NormalizeBundleUpgradeCode(bundleSymbol.SourceLineNumbers, bundleSymbol.UpgradeCode); | ||
106 | |||
107 | bundleSymbol.Attributes |= WixBundleAttributes.PerMachine; // default to per-machine but the first-per user package wil flip the bundle per-user. | 105 | bundleSymbol.Attributes |= WixBundleAttributes.PerMachine; // default to per-machine but the first-per user package wil flip the bundle per-user. |
108 | 106 | ||
107 | this.NormalizeRelatedBundles(bundleSymbol, section); | ||
108 | |||
109 | // Ensure there is one and only one WixBootstrapperApplicationDllSymbol. | 109 | // Ensure there is one and only one WixBootstrapperApplicationDllSymbol. |
110 | // The compiler and linker behavior should have colluded to get | 110 | // The compiler and linker behavior should have colluded to get |
111 | // this behavior. | 111 | // this behavior. |
@@ -178,33 +178,33 @@ namespace WixToolset.Core.Burn | |||
178 | { | 178 | { |
179 | switch (facade.PackageSymbol.Type) | 179 | switch (facade.PackageSymbol.Type) |
180 | { | 180 | { |
181 | case WixBundlePackageType.Exe: | 181 | case WixBundlePackageType.Exe: |
182 | { | 182 | { |
183 | var command = new ProcessExePackageCommand(facade, payloadSymbols); | 183 | var command = new ProcessExePackageCommand(facade, payloadSymbols); |
184 | command.Execute(); | 184 | command.Execute(); |
185 | } | 185 | } |
186 | break; | 186 | break; |
187 | 187 | ||
188 | case WixBundlePackageType.Msi: | 188 | case WixBundlePackageType.Msi: |
189 | { | 189 | { |
190 | var command = new ProcessMsiPackageCommand(this.ServiceProvider, this.BackendExtensions, section, facade, packagesPayloads[facade.PackageId]); | 190 | var command = new ProcessMsiPackageCommand(this.ServiceProvider, this.BackendExtensions, section, facade, packagesPayloads[facade.PackageId]); |
191 | command.Execute(); | 191 | command.Execute(); |
192 | } | 192 | } |
193 | break; | 193 | break; |
194 | 194 | ||
195 | case WixBundlePackageType.Msp: | 195 | case WixBundlePackageType.Msp: |
196 | { | 196 | { |
197 | var command = new ProcessMspPackageCommand(this.Messaging, section, facade, payloadSymbols); | 197 | var command = new ProcessMspPackageCommand(this.Messaging, section, facade, payloadSymbols); |
198 | command.Execute(); | 198 | command.Execute(); |
199 | } | 199 | } |
200 | break; | 200 | break; |
201 | 201 | ||
202 | case WixBundlePackageType.Msu: | 202 | case WixBundlePackageType.Msu: |
203 | { | 203 | { |
204 | var command = new ProcessMsuPackageCommand(facade, payloadSymbols); | 204 | var command = new ProcessMsuPackageCommand(facade, payloadSymbols); |
205 | command.Execute(); | 205 | command.Execute(); |
206 | } | 206 | } |
207 | break; | 207 | break; |
208 | } | 208 | } |
209 | 209 | ||
210 | if (null != variableCache) | 210 | if (null != variableCache) |
@@ -496,18 +496,39 @@ namespace WixToolset.Core.Burn | |||
496 | this.Wixout = this.CreateWixout(trackedFiles, this.Output, manifestPath, baManifestPath, bextManifestPath); | 496 | this.Wixout = this.CreateWixout(trackedFiles, this.Output, manifestPath, baManifestPath, bextManifestPath); |
497 | } | 497 | } |
498 | 498 | ||
499 | private string NormalizeBundleUpgradeCode(SourceLineNumber sourceLineNumber, string upgradeCode) | 499 | private void NormalizeRelatedBundles(WixBundleSymbol bundleSymbol, IntermediateSection section) |
500 | { | 500 | { |
501 | if (Guid.TryParse(upgradeCode, out var guid)) | 501 | var upgradeCode = bundleSymbol.UpgradeCode; |
502 | |||
503 | foreach (var relatedBundleSymbol in section.Symbols.OfType<WixRelatedBundleSymbol>()) | ||
504 | { | ||
505 | var elementName = "RelatedBundle"; | ||
506 | var attributeName = "Id"; | ||
507 | |||
508 | if (upgradeCode == relatedBundleSymbol.BundleId) | ||
509 | { | ||
510 | elementName = "Bundle"; | ||
511 | attributeName = "UpgradeCode"; | ||
512 | } | ||
513 | |||
514 | relatedBundleSymbol.BundleId = this.NormalizeBundleRelatedBundleId(relatedBundleSymbol.SourceLineNumbers, relatedBundleSymbol.BundleId, elementName, attributeName); | ||
515 | } | ||
516 | |||
517 | bundleSymbol.UpgradeCode = this.NormalizeBundleRelatedBundleId(bundleSymbol.SourceLineNumbers, bundleSymbol.UpgradeCode, null, null); | ||
518 | } | ||
519 | |||
520 | private string NormalizeBundleRelatedBundleId(SourceLineNumber sourceLineNumber, string relatedBundleId, string elementName, string attributeName) | ||
521 | { | ||
522 | if (Guid.TryParse(relatedBundleId, out var guid)) | ||
502 | { | 523 | { |
503 | return guid.ToString("B").ToUpperInvariant(); | 524 | return guid.ToString("B").ToUpperInvariant(); |
504 | } | 525 | } |
505 | else | 526 | else if (!String.IsNullOrEmpty(elementName)) |
506 | { | 527 | { |
507 | this.Messaging.Write(ErrorMessages.IllegalGuidValue(sourceLineNumber, "Bundle", "UpgradeCode", upgradeCode)); | 528 | this.Messaging.Write(ErrorMessages.IllegalGuidValue(sourceLineNumber, elementName, attributeName, relatedBundleId)); |
508 | } | 529 | } |
509 | 530 | ||
510 | return upgradeCode; | 531 | return relatedBundleId; |
511 | } | 532 | } |
512 | 533 | ||
513 | private WixOutput CreateWixout(List<ITrackedFile> trackedFiles, Intermediate intermediate, string manifestPath, string baDataPath, string bextDataPath) | 534 | private WixOutput CreateWixout(List<ITrackedFile> trackedFiles, Intermediate intermediate, string manifestPath, string baDataPath, string bextDataPath) |
@@ -552,7 +573,7 @@ namespace WixToolset.Core.Burn | |||
552 | variableCache.Add(String.Concat("packageVersion.", id), package.Version); | 573 | variableCache.Add(String.Concat("packageVersion.", id), package.Version); |
553 | 574 | ||
554 | if (facade.SpecificPackageSymbol is WixBundleMsiPackageSymbol msiPackage) | 575 | if (facade.SpecificPackageSymbol is WixBundleMsiPackageSymbol msiPackage) |
555 | { | 576 | { |
556 | variableCache.Add(String.Concat("packageLanguage.", id), msiPackage.ProductLanguage.ToString()); | 577 | variableCache.Add(String.Concat("packageLanguage.", id), msiPackage.ProductLanguage.ToString()); |
557 | variableCache.Add(String.Concat("packageManufacturer.", id), msiPackage.Manufacturer ?? String.Empty); | 578 | variableCache.Add(String.Concat("packageManufacturer.", id), msiPackage.Manufacturer ?? String.Empty); |
558 | } | 579 | } |
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/BundleFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/BundleFixture.cs index 4ac9c3a4..e4a57d4d 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/BundleFixture.cs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/BundleFixture.cs | |||
@@ -332,8 +332,8 @@ namespace WixToolsetTest.CoreIntegration | |||
332 | var result = WixRunner.Execute(new[] | 332 | var result = WixRunner.Execute(new[] |
333 | { | 333 | { |
334 | "build", | 334 | "build", |
335 | Path.Combine(folder, "BundleWithInvalid", "BundleWithInvalidUpgradeCode.wxs"), | 335 | Path.Combine(folder, "BundleLocalized", "BundleWithLocalizedUpgradeCode.wxs"), |
336 | "-loc", Path.Combine(folder, "BundleWithInvalid", "BundleWithInvalidUpgradeCode.wxl"), | 336 | "-loc", Path.Combine(folder, "BundleLocalized", "BundleWithInvalidUpgradeCode.wxl"), |
337 | "-bindpath", Path.Combine(folder, ".Data"), | 337 | "-bindpath", Path.Combine(folder, ".Data"), |
338 | "-bindpath", Path.Combine(folder, "SimpleBundle", "data"), | 338 | "-bindpath", Path.Combine(folder, "SimpleBundle", "data"), |
339 | "-intermediateFolder", intermediateFolder, | 339 | "-intermediateFolder", intermediateFolder, |
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/BundleManifestFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/BundleManifestFixture.cs index 29c9dd95..7f92f90b 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/BundleManifestFixture.cs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/BundleManifestFixture.cs | |||
@@ -139,6 +139,49 @@ namespace WixToolsetTest.CoreIntegration | |||
139 | } | 139 | } |
140 | 140 | ||
141 | [Fact] | 141 | [Fact] |
142 | public void CanBuildBundleManifestWithNormalizedRelatedBundles() | ||
143 | { | ||
144 | var folder = TestData.Get(@"TestData"); | ||
145 | |||
146 | using (var fs = new DisposableFileSystem()) | ||
147 | { | ||
148 | var baseFolder = fs.GetFolder(); | ||
149 | var intermediateFolder = Path.Combine(baseFolder, "obj"); | ||
150 | var bundlePath = Path.Combine(baseFolder, @"bin\test.exe"); | ||
151 | var baFolderPath = Path.Combine(baseFolder, "ba"); | ||
152 | var extractFolderPath = Path.Combine(baseFolder, "extract"); | ||
153 | |||
154 | var result = WixRunner.Execute(new[] | ||
155 | { | ||
156 | "build", | ||
157 | Path.Combine(folder, "BundleLocalized", "BundleWithLocalizedUpgradeCode.wxs"), | ||
158 | "-loc", Path.Combine(folder, "BundleLocalized", "BundleWithValidUpgradeCode.wxl"), | ||
159 | "-bindpath", Path.Combine(folder, ".Data"), | ||
160 | "-bindpath", Path.Combine(folder, "SimpleBundle", "data"), | ||
161 | "-intermediateFolder", intermediateFolder, | ||
162 | "-o", Path.Combine(baseFolder, @"bin\test.exe") | ||
163 | }); | ||
164 | |||
165 | result.AssertSuccess(); | ||
166 | |||
167 | var extractResult = BundleExtractor.ExtractBAContainer(null, bundlePath, baFolderPath, extractFolderPath); | ||
168 | extractResult.AssertSuccess(); | ||
169 | |||
170 | var manifestRelatedBundlesElements = extractResult.SelectManifestNodes("/burn:BurnManifest/burn:RelatedBundle"); | ||
171 | Assert.Equal("<RelatedBundle Id='{6D4CE32B-FB91-45DA-A9B5-7E0D9929A3C3}' Action='Upgrade' />", manifestRelatedBundlesElements[0].GetTestXml()); | ||
172 | Assert.Equal(1, manifestRelatedBundlesElements.Count); | ||
173 | |||
174 | var dataRelatedBundlesElements = extractResult.SelectBADataNodes("/ba:BootstrapperApplicationData/ba:WixBundleProperties"); | ||
175 | var ignoreAttributesByElementName = new Dictionary<string, List<string>> | ||
176 | { | ||
177 | { "WixBundleProperties", new List<string> { "DisplayName", "Id" } }, | ||
178 | }; | ||
179 | Assert.Equal("<WixBundleProperties DisplayName='*' LogPathVariable='WixBundleLog' Compressed='no' Id='*' UpgradeCode='{6D4CE32B-FB91-45DA-A9B5-7E0D9929A3C3}' PerMachine='yes' />", dataRelatedBundlesElements[0].GetTestXml(ignoreAttributesByElementName)); | ||
180 | Assert.Equal(1, dataRelatedBundlesElements.Count); | ||
181 | } | ||
182 | } | ||
183 | |||
184 | [Fact] | ||
142 | public void PopulatesBEManifestWithBundleExtensionBundleCustomData() | 185 | public void PopulatesBEManifestWithBundleExtensionBundleCustomData() |
143 | { | 186 | { |
144 | var folder = TestData.Get(@"TestData"); | 187 | var folder = TestData.Get(@"TestData"); |
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/BundleWithInvalid/BundleWithInvalidUpgradeCode.wxl b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/BundleLocalized/BundleWithInvalidUpgradeCode.wxl index 40688f36..92e1b746 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/BundleWithInvalid/BundleWithInvalidUpgradeCode.wxl +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/BundleLocalized/BundleWithInvalidUpgradeCode.wxl | |||
@@ -1,3 +1,3 @@ | |||
1 | <WixLocalization xmlns="http://wixtoolset.org/schemas/v4/wxl" Culture="en-US"> | 1 | <WixLocalization xmlns="http://wixtoolset.org/schemas/v4/wxl" Culture="en-US"> |
2 | <String Id="InvalidUpgradeCode">NOT-A-GUID</String> | 2 | <String Id="UpgradeCode">NOT-A-GUID</String> |
3 | </WixLocalization> | 3 | </WixLocalization> |
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/BundleWithInvalid/BundleWithInvalidUpgradeCode.wxs b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/BundleLocalized/BundleWithLocalizedUpgradeCode.wxs index dce57226..d9d7f33a 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/BundleWithInvalid/BundleWithInvalidUpgradeCode.wxs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/BundleLocalized/BundleWithLocalizedUpgradeCode.wxs | |||
@@ -1,6 +1,6 @@ | |||
1 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> | 1 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> |
2 | <Bundle Name="BundleWithInvalidUpgradeCode" | 2 | <Bundle Name="BundleWithInvalidUpgradeCode" |
3 | Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="!(loc.InvalidUpgradeCode)"> | 3 | Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="!(loc.UpgradeCode)"> |
4 | <BootstrapperApplication> | 4 | <BootstrapperApplication> |
5 | <BootstrapperApplicationDll SourceFile="fakeba.dll" /> | 5 | <BootstrapperApplicationDll SourceFile="fakeba.dll" /> |
6 | </BootstrapperApplication> | 6 | </BootstrapperApplication> |
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/BundleLocalized/BundleWithValidUpgradeCode.wxl b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/BundleLocalized/BundleWithValidUpgradeCode.wxl new file mode 100644 index 00000000..c5731331 --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/BundleLocalized/BundleWithValidUpgradeCode.wxl | |||
@@ -0,0 +1,3 @@ | |||
1 | <WixLocalization xmlns="http://wixtoolset.org/schemas/v4/wxl" Culture="en-US"> | ||
2 | <String Id="UpgradeCode">6d4ce32b-fb91-45da-a9b5-7e0d9929a3c3</String> | ||
3 | </WixLocalization> | ||