aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2022-04-13 10:12:22 -0500
committerSean Hall <r.sean.hall@gmail.com>2022-04-13 13:13:48 -0500
commit17d4ba9d93814cffa688e9152d11a340f9e0f754 (patch)
treea990dc48e971301762f5b462c801a26896e4e2b8
parent68e54edc630099137b30ab946a80a8231a0d3d44 (diff)
downloadwix-17d4ba9d93814cffa688e9152d11a340f9e0f754.tar.gz
wix-17d4ba9d93814cffa688e9152d11a340f9e0f754.tar.bz2
wix-17d4ba9d93814cffa688e9152d11a340f9e0f754.zip
Discard the correct RollbackBoundary.
-rw-r--r--src/wix/WixToolset.Core.Burn/Bind/GenerateManifestDataFromIRCommand.cs6
-rw-r--r--src/wix/WixToolset.Core.Burn/Bundles/OrderPackagesAndRollbackBoundariesCommand.cs13
-rw-r--r--src/wix/test/WixToolsetTest.CoreIntegration/RollbackBoundaryFixture.cs105
-rw-r--r--src/wix/test/WixToolsetTest.CoreIntegration/TestData/RollbackBoundary/ConsecutiveRollbackBoundaries.wxs13
-rw-r--r--src/wix/test/WixToolsetTest.CoreIntegration/TestData/RollbackBoundary/SharedIdWithPackage.wxs9
5 files changed, 135 insertions, 11 deletions
diff --git a/src/wix/WixToolset.Core.Burn/Bind/GenerateManifestDataFromIRCommand.cs b/src/wix/WixToolset.Core.Burn/Bind/GenerateManifestDataFromIRCommand.cs
index 9d214211..396e0eff 100644
--- a/src/wix/WixToolset.Core.Burn/Bind/GenerateManifestDataFromIRCommand.cs
+++ b/src/wix/WixToolset.Core.Burn/Bind/GenerateManifestDataFromIRCommand.cs
@@ -94,6 +94,7 @@ namespace WixToolset.Core.Burn.Bind
94 case SymbolDefinitionType.WixBundleVariable: 94 case SymbolDefinitionType.WixBundleVariable:
95 case SymbolDefinitionType.WixBuildInfo: 95 case SymbolDefinitionType.WixBuildInfo:
96 case SymbolDefinitionType.WixChain: 96 case SymbolDefinitionType.WixChain:
97 case SymbolDefinitionType.WixChainItem:
97 case SymbolDefinitionType.WixComponentSearch: 98 case SymbolDefinitionType.WixComponentSearch:
98 case SymbolDefinitionType.WixDependencyProvider: 99 case SymbolDefinitionType.WixDependencyProvider:
99 case SymbolDefinitionType.WixFileSearch: 100 case SymbolDefinitionType.WixFileSearch:
@@ -114,10 +115,7 @@ namespace WixToolset.Core.Burn.Bind
114 case SymbolDefinitionType.WixVariable: 115 case SymbolDefinitionType.WixVariable:
115 break; 116 break;
116 117
117 // Symbols to investigate: 118 // All other symbols need to be processed.
118 case SymbolDefinitionType.WixChainItem:
119 break;
120
121 case SymbolDefinitionType.WixBundleCustomData: 119 case SymbolDefinitionType.WixBundleCustomData:
122 unknownSymbol = !this.IndexBundleCustomDataSymbol((WixBundleCustomDataSymbol)symbol, customDataById); 120 unknownSymbol = !this.IndexBundleCustomDataSymbol((WixBundleCustomDataSymbol)symbol, customDataById);
123 break; 121 break;
diff --git a/src/wix/WixToolset.Core.Burn/Bundles/OrderPackagesAndRollbackBoundariesCommand.cs b/src/wix/WixToolset.Core.Burn/Bundles/OrderPackagesAndRollbackBoundariesCommand.cs
index ccf6b1c2..df798583 100644
--- a/src/wix/WixToolset.Core.Burn/Bundles/OrderPackagesAndRollbackBoundariesCommand.cs
+++ b/src/wix/WixToolset.Core.Burn/Bundles/OrderPackagesAndRollbackBoundariesCommand.cs
@@ -94,15 +94,14 @@ namespace WixToolset.Core.Burn.Bundles
94 { 94 {
95 // Discard the next rollback boundary if we have a previously defined boundary. 95 // Discard the next rollback boundary if we have a previously defined boundary.
96 var nextRollbackBoundary = boundariesById[groupSymbol.ChildId]; 96 var nextRollbackBoundary = boundariesById[groupSymbol.ChildId];
97 if (null != pendingRollbackBoundary) 97 if (null != pendingRollbackBoundary && pendingRollbackBoundary.Id.Id != BurnConstants.BundleDefaultBoundaryId)
98 { 98 {
99 if (pendingRollbackBoundary.Id.Id != BurnConstants.BundleDefaultBoundaryId) 99 this.Messaging.Write(WarningMessages.DiscardedRollbackBoundary(nextRollbackBoundary.SourceLineNumbers, nextRollbackBoundary.Id.Id));
100 { 100 }
101 this.Messaging.Write(WarningMessages.DiscardedRollbackBoundary(nextRollbackBoundary.SourceLineNumbers, nextRollbackBoundary.Id.Id)); 101 else
102 } 102 {
103 lastRollbackBoundary = pendingRollbackBoundary = nextRollbackBoundary;
103 } 104 }
104
105 lastRollbackBoundary = pendingRollbackBoundary = nextRollbackBoundary;
106 } 105 }
107 } 106 }
108 } 107 }
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/RollbackBoundaryFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/RollbackBoundaryFixture.cs
index 9e19abb0..c69ff894 100644
--- a/src/wix/test/WixToolsetTest.CoreIntegration/RollbackBoundaryFixture.cs
+++ b/src/wix/test/WixToolsetTest.CoreIntegration/RollbackBoundaryFixture.cs
@@ -2,7 +2,10 @@
2 2
3namespace WixToolsetTest.CoreIntegration 3namespace WixToolsetTest.CoreIntegration
4{ 4{
5 using System.Collections.Generic;
5 using System.IO; 6 using System.IO;
7 using System.Linq;
8 using System.Xml;
6 using WixBuildTools.TestSupport; 9 using WixBuildTools.TestSupport;
7 using WixToolset.Core.TestPackage; 10 using WixToolset.Core.TestPackage;
8 using Xunit; 11 using Xunit;
@@ -37,5 +40,107 @@ namespace WixToolsetTest.CoreIntegration
37 } 40 }
38 } 41 }
39 42
43 [Fact]
44 public void CannotHaveRollbackBoundaryAndChainPackageWithSameId()
45 {
46 var folder = TestData.Get(@"TestData");
47
48 using (var fs = new DisposableFileSystem())
49 {
50 var baseFolder = fs.GetFolder();
51 var intermediateFolder = Path.Combine(baseFolder, "obj");
52 var exePath = Path.Combine(baseFolder, @"bin\test.exe");
53
54 var result = WixRunner.Execute(new[]
55 {
56 "build",
57 Path.Combine(folder, "RollbackBoundary", "SharedIdWithPackage.wxs"),
58 Path.Combine(folder, "BundleWithPackageGroupRef", "Bundle.wxs"),
59 Path.Combine(folder, "BundleWithPackageGroupRef", "MinimalPackageGroup.wxs"),
60 "-bindpath", Path.Combine(folder, "SimpleBundle", "data"),
61 "-intermediateFolder", intermediateFolder,
62 "-o", exePath,
63 });
64
65 Assert.Equal(92, result.ExitCode);
66
67 WixAssert.CompareLineByLine(new[]
68 {
69 "Duplicate symbol 'WixChainItem:collision' found. This typically means that an Id is duplicated. Access modifiers (internal, protected, private) cannot prevent these conflicts. Ensure all your identifiers of a given type (File, Component, Feature) are unique.",
70 "Location of symbol related to previous error.",
71 }, result.Messages.Select(m => m.ToString()).ToArray());
72
73 Assert.False(File.Exists(exePath));
74 }
75 }
76
77 [Fact]
78 public void DiscardsConsecutiveRollbackBoundaries()
79 {
80 var folder = TestData.Get(@"TestData");
81
82 using (var fs = new DisposableFileSystem())
83 {
84 var baseFolder = fs.GetFolder();
85 var intermediateFolder = Path.Combine(baseFolder, "obj");
86 var exePath = Path.Combine(baseFolder, @"bin\test.exe");
87 var baFolderPath = Path.Combine(baseFolder, "ba");
88 var extractFolderPath = Path.Combine(baseFolder, "extract");
89
90 var result = WixRunner.Execute(false, new[]
91 {
92 "build",
93 Path.Combine(folder, "RollbackBoundary", "ConsecutiveRollbackBoundaries.wxs"),
94 Path.Combine(folder, "BundleWithPackageGroupRef", "Bundle.wxs"),
95 Path.Combine(folder, "BundleWithPackageGroupRef", "MinimalPackageGroup.wxs"),
96 "-bindpath", Path.Combine(folder, "SimpleBundle", "data"),
97 "-intermediateFolder", intermediateFolder,
98 "-o", exePath,
99 });
100
101 result.AssertSuccess();
102
103 WixAssert.CompareLineByLine(new[]
104 {
105 "The RollbackBoundary 'Second' was discarded because it was not followed by a package. Without a package the rollback boundary doesn't do anything. Verify that the RollbackBoundary element is not followed by another RollbackBoundary and that the element is not at the end of the chain.",
106 }, result.Messages.Select(m => m.ToString()).ToArray());
107
108 Assert.True(File.Exists(exePath));
109
110 var extractResult = BundleExtractor.ExtractBAContainer(null, exePath, baFolderPath, extractFolderPath);
111 extractResult.AssertSuccess();
112
113 var rollbackBoundaries = extractResult.SelectManifestNodes("/burn:BurnManifest/burn:RollbackBoundary")
114 .Cast<XmlElement>()
115 .Select(e => e.GetTestXml())
116 .ToArray();
117 WixAssert.CompareLineByLine(new string[]
118 {
119 "<RollbackBoundary Id='First' Vital='yes' Transaction='no' />",
120 }, rollbackBoundaries);
121
122 var ignoreAttributesByElementName = new Dictionary<string, List<string>>
123 {
124 { "MsiPackage", new List<string> { "Size" } },
125 };
126 var chainPackages = extractResult.SelectManifestNodes("/burn:BurnManifest/burn:Chain/*")
127 .Cast<XmlElement>()
128 .Select(e => e.GetTestXml(ignoreAttributesByElementName))
129 .ToArray();
130 WixAssert.CompareLineByLine(new string[]
131 {
132 "<MsiPackage Id='test.msi' Cache='keep' CacheId='{040011E1-F84C-4927-AD62-50A5EC19CA32}v1.0.0.0' InstallSize='34' Size='*' PerMachine='yes' Permanent='no' Vital='yes' RollbackBoundaryForward='First' RollbackBoundaryBackward='First' LogPathVariable='WixBundleLog_test.msi' RollbackLogPathVariable='WixBundleRollbackLog_test.msi' ProductCode='{040011E1-F84C-4927-AD62-50A5EC19CA32}' Language='1033' Version='1.0.0.0' UpgradeCode='{047730A5-30FE-4A62-A520-DA9381B8226A}'>" +
133 "<MsiProperty Id='ARPSYSTEMCOMPONENT' Value='1' />" +
134 "<MsiProperty Id='MSIFASTINSTALL' Value='7' />" +
135 "<Provides Key='{040011E1-F84C-4927-AD62-50A5EC19CA32}_v1.0.0.0' Version='1.0.0.0' DisplayName='MsiPackage' />" +
136 "<RelatedPackage Id='{047730A5-30FE-4A62-A520-DA9381B8226A}' MaxVersion='1.0.0.0' MaxInclusive='no' OnlyDetect='no' LangInclusive='yes'><Language Id='1033' /></RelatedPackage>" +
137 "<RelatedPackage Id='{047730A5-30FE-4A62-A520-DA9381B8226A}' MinVersion='1.0.0.0' MinInclusive='no' OnlyDetect='yes' LangInclusive='yes'><Language Id='1033' /></RelatedPackage>" +
138 "<PayloadRef Id='test.msi' />" +
139 "<PayloadRef Id='fhuZsOcBDTuIX8rF96kswqI6SnuI' />" +
140 "<PayloadRef Id='faf_OZ741BG7SJ6ZkcIvivZ2Yzo8' />" +
141 "</MsiPackage>",
142 }, chainPackages);
143 }
144 }
40 } 145 }
41} 146}
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/RollbackBoundary/ConsecutiveRollbackBoundaries.wxs b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/RollbackBoundary/ConsecutiveRollbackBoundaries.wxs
new file mode 100644
index 00000000..e12b5656
--- /dev/null
+++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/RollbackBoundary/ConsecutiveRollbackBoundaries.wxs
@@ -0,0 +1,13 @@
1<?xml version="1.0" encoding="utf-8"?>
2<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
3 <Fragment>
4 <PackageGroup Id="PreBundlePackages">
5 <RollbackBoundary Id="First" />
6 </PackageGroup>
7 <PackageGroup Id="BundlePackages">
8 <PackageGroupRef Id="PreBundlePackages" />
9 <RollbackBoundary Id="Second" />
10 <MsiPackage SourceFile="test.msi" />
11 </PackageGroup>
12 </Fragment>
13</Wix>
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/RollbackBoundary/SharedIdWithPackage.wxs b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/RollbackBoundary/SharedIdWithPackage.wxs
new file mode 100644
index 00000000..8a7a21a7
--- /dev/null
+++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/RollbackBoundary/SharedIdWithPackage.wxs
@@ -0,0 +1,9 @@
1<?xml version="1.0" encoding="utf-8"?>
2<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
3 <Fragment>
4 <PackageGroup Id="BundlePackages">
5 <RollbackBoundary Id="collision" />
6 <MsiPackage Id="collision" SourceFile="test.msi" />
7 </PackageGroup>
8 </Fragment>
9</Wix>