diff options
author | Rob Mensching <rob@firegiant.com> | 2022-03-11 17:16:23 -0800 |
---|---|---|
committer | Rob Mensching <rob@firegiant.com> | 2022-03-14 12:50:55 -0700 |
commit | 02b8f1a145724d889f95761390dc6223289764ac (patch) | |
tree | b7e779b52bb2db75e15e91da73190304cbe78786 | |
parent | 8b959ca40baf44454d03fd14ef98482c52417681 (diff) | |
download | wix-02b8f1a145724d889f95761390dc6223289764ac.tar.gz wix-02b8f1a145724d889f95761390dc6223289764ac.tar.bz2 wix-02b8f1a145724d889f95761390dc6223289764ac.zip |
Always try to normalize the Bundle UpgradeCode in the backend
Fixes 6008
4 files changed, 59 insertions, 0 deletions
diff --git a/src/wix/WixToolset.Core.Burn/Bind/BindBundleCommand.cs b/src/wix/WixToolset.Core.Burn/Bind/BindBundleCommand.cs index 7b74ce5e..eb822fba 100644 --- a/src/wix/WixToolset.Core.Burn/Bind/BindBundleCommand.cs +++ b/src/wix/WixToolset.Core.Burn/Bind/BindBundleCommand.cs | |||
@@ -102,6 +102,8 @@ 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 | |||
105 | bundleSymbol.Attributes |= WixBundleAttributes.PerMachine; // default to per-machine but the first-per user package wil flip the bundle per-user. | 107 | bundleSymbol.Attributes |= WixBundleAttributes.PerMachine; // default to per-machine but the first-per user package wil flip the bundle per-user. |
106 | 108 | ||
107 | // Ensure there is one and only one WixBootstrapperApplicationDllSymbol. | 109 | // Ensure there is one and only one WixBootstrapperApplicationDllSymbol. |
@@ -494,6 +496,20 @@ namespace WixToolset.Core.Burn | |||
494 | this.Wixout = this.CreateWixout(trackedFiles, this.Output, manifestPath, baManifestPath, bextManifestPath); | 496 | this.Wixout = this.CreateWixout(trackedFiles, this.Output, manifestPath, baManifestPath, bextManifestPath); |
495 | } | 497 | } |
496 | 498 | ||
499 | private string NormalizeBundleUpgradeCode(SourceLineNumber sourceLineNumber, string upgradeCode) | ||
500 | { | ||
501 | if (Guid.TryParse(upgradeCode, out var guid)) | ||
502 | { | ||
503 | return guid.ToString("B").ToUpperInvariant(); | ||
504 | } | ||
505 | else | ||
506 | { | ||
507 | this.Messaging.Write(ErrorMessages.IllegalGuidValue(sourceLineNumber, "Bundle", "UpgradeCode", upgradeCode)); | ||
508 | } | ||
509 | |||
510 | return upgradeCode; | ||
511 | } | ||
512 | |||
497 | private WixOutput CreateWixout(List<ITrackedFile> trackedFiles, Intermediate intermediate, string manifestPath, string baDataPath, string bextDataPath) | 513 | private WixOutput CreateWixout(List<ITrackedFile> trackedFiles, Intermediate intermediate, string manifestPath, string baDataPath, string bextDataPath) |
498 | { | 514 | { |
499 | WixOutput wixout; | 515 | WixOutput wixout; |
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/BundleFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/BundleFixture.cs index 2328d762..77b122da 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/BundleFixture.cs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/BundleFixture.cs | |||
@@ -320,6 +320,35 @@ namespace WixToolsetTest.CoreIntegration | |||
320 | } | 320 | } |
321 | 321 | ||
322 | [Fact] | 322 | [Fact] |
323 | public void CannotBuildBundleWithInvalidUpgradeCode() | ||
324 | { | ||
325 | var folder = TestData.Get(@"TestData"); | ||
326 | |||
327 | using (var fs = new DisposableFileSystem()) | ||
328 | { | ||
329 | var baseFolder = fs.GetFolder(); | ||
330 | var intermediateFolder = Path.Combine(baseFolder, "obj"); | ||
331 | |||
332 | var result = WixRunner.Execute(new[] | ||
333 | { | ||
334 | "build", | ||
335 | Path.Combine(folder, "BundleWithInvalid", "BundleWithInvalidUpgradeCode.wxs"), | ||
336 | "-loc", Path.Combine(folder, "BundleWithInvalid", "BundleWithInvalidUpgradeCode.wxl"), | ||
337 | "-bindpath", Path.Combine(folder, ".Data"), | ||
338 | "-bindpath", Path.Combine(folder, "SimpleBundle", "data"), | ||
339 | "-intermediateFolder", intermediateFolder, | ||
340 | "-o", Path.Combine(baseFolder, @"bin\test.exe") | ||
341 | }); | ||
342 | |||
343 | var message = result.Messages.Where(m => m.Level == MessageLevel.Error).Select(m => m.ToString().Replace(folder, "<testdata>")).ToArray(); | ||
344 | WixAssert.CompareLineByLine(new[] | ||
345 | { | ||
346 | "The Bundle/@UpgradeCode attribute's value, 'NOT-A-GUID', is not a legal guid value." | ||
347 | }, message); | ||
348 | } | ||
349 | } | ||
350 | |||
351 | [Fact] | ||
323 | public void CanBuildUncompressedBundle() | 352 | public void CanBuildUncompressedBundle() |
324 | { | 353 | { |
325 | var folder = TestData.Get(@"TestData") + Path.DirectorySeparatorChar; | 354 | var folder = TestData.Get(@"TestData") + Path.DirectorySeparatorChar; |
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/BundleWithInvalid/BundleWithInvalidUpgradeCode.wxl b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/BundleWithInvalid/BundleWithInvalidUpgradeCode.wxl new file mode 100644 index 00000000..40688f36 --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/BundleWithInvalid/BundleWithInvalidUpgradeCode.wxl | |||
@@ -0,0 +1,3 @@ | |||
1 | <WixLocalization xmlns="http://wixtoolset.org/schemas/v4/wxl" Culture="en-US"> | ||
2 | <String Id="InvalidUpgradeCode">NOT-A-GUID</String> | ||
3 | </WixLocalization> | ||
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/BundleWithInvalid/BundleWithInvalidUpgradeCode.wxs b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/BundleWithInvalid/BundleWithInvalidUpgradeCode.wxs new file mode 100644 index 00000000..dce57226 --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/BundleWithInvalid/BundleWithInvalidUpgradeCode.wxs | |||
@@ -0,0 +1,11 @@ | |||
1 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> | ||
2 | <Bundle Name="BundleWithInvalidUpgradeCode" | ||
3 | Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="!(loc.InvalidUpgradeCode)"> | ||
4 | <BootstrapperApplication> | ||
5 | <BootstrapperApplicationDll SourceFile="fakeba.dll" /> | ||
6 | </BootstrapperApplication> | ||
7 | <Chain> | ||
8 | <ExePackage DetectCondition="DetectedSomething" UninstallArguments="-uninstall" SourceFile="burn.exe" /> | ||
9 | </Chain> | ||
10 | </Bundle> | ||
11 | </Wix> | ||