diff options
author | Rob Mensching <rob@firegiant.com> | 2024-12-28 23:51:28 -0800 |
---|---|---|
committer | Rob Mensching <rob@firegiant.com> | 2024-12-29 08:08:58 -0800 |
commit | 4d6476d43973bc4ebee1ff246fb3e5c88b024bc4 (patch) | |
tree | 7d214e457b7409f4364f1dd1be7dca5eef40afcb /src | |
parent | a4fb0e4ca241591e36917bd98f06174fe65c4124 (diff) | |
download | wix-4d6476d43973bc4ebee1ff246fb3e5c88b024bc4.tar.gz wix-4d6476d43973bc4ebee1ff246fb3e5c88b024bc4.tar.bz2 wix-4d6476d43973bc4ebee1ff246fb3e5c88b024bc4.zip |
Overridable WixVariables should be treated as virtual
Fixes 8528
Diffstat (limited to 'src')
3 files changed, 51 insertions, 6 deletions
diff --git a/src/wix/WixToolset.Core/Compiler_Package.cs b/src/wix/WixToolset.Core/Compiler_Package.cs index 853c6ed2..479a1ab3 100644 --- a/src/wix/WixToolset.Core/Compiler_Package.cs +++ b/src/wix/WixToolset.Core/Compiler_Package.cs | |||
@@ -5033,6 +5033,11 @@ namespace WixToolset.Core | |||
5033 | 5033 | ||
5034 | if (!this.Core.EncounteredError) | 5034 | if (!this.Core.EncounteredError) |
5035 | { | 5035 | { |
5036 | if (overridable) | ||
5037 | { | ||
5038 | id = new Identifier(AccessModifier.Virtual, id.Id); | ||
5039 | } | ||
5040 | |||
5036 | this.Core.AddSymbol(new WixVariableSymbol(sourceLineNumbers, id) | 5041 | this.Core.AddSymbol(new WixVariableSymbol(sourceLineNumbers, id) |
5037 | { | 5042 | { |
5038 | Value = value, | 5043 | Value = value, |
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/WixVariable/PackageWithOverriddenBindVariable.wxs b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/WixVariable/PackageWithOverriddenBindVariable.wxs new file mode 100644 index 00000000..fdc2a461 --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/WixVariable/PackageWithOverriddenBindVariable.wxs | |||
@@ -0,0 +1,13 @@ | |||
1 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> | ||
2 | <Package Version="1.0.0" Name="MsiPackage" Manufacturer="Example Corporation" UpgradeCode="047730a5-30fe-4a62-a520-da9381b8226a"> | ||
3 | <PropertyRef Id="Test" /> | ||
4 | |||
5 | <WixVariable Id="override TestWixVariable" Value="0"/> | ||
6 | </Package> | ||
7 | |||
8 | <Fragment> | ||
9 | <Property Id="Test" Value="!(wix.TestWixVariable)" /> | ||
10 | |||
11 | <WixVariable Id="TestWixVariable" Value="1" Overridable="true"/> | ||
12 | </Fragment> | ||
13 | </Wix> | ||
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/WixVariableFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/WixVariableFixture.cs index 50199b74..b6aea217 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/WixVariableFixture.cs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/WixVariableFixture.cs | |||
@@ -35,7 +35,7 @@ namespace WixToolsetTest.CoreIntegration | |||
35 | 35 | ||
36 | result.AssertSuccess(); | 36 | result.AssertSuccess(); |
37 | 37 | ||
38 | var productVersion = GetProductVersionFromMsi(msiPath); | 38 | var productVersion = GetPropertyFromMsi(msiPath, "ProductVersion"); |
39 | Assert.Equal("4.3.2.1", productVersion); | 39 | Assert.Equal("4.3.2.1", productVersion); |
40 | } | 40 | } |
41 | } | 41 | } |
@@ -62,7 +62,7 @@ namespace WixToolsetTest.CoreIntegration | |||
62 | 62 | ||
63 | result.AssertSuccess(); | 63 | result.AssertSuccess(); |
64 | 64 | ||
65 | var productVersion = GetProductVersionFromMsi(msiPath); | 65 | var productVersion = GetPropertyFromMsi(msiPath, "ProductVersion"); |
66 | Assert.Equal("1.1.1.1", productVersion); | 66 | Assert.Equal("1.1.1.1", productVersion); |
67 | 67 | ||
68 | var directoryTable = Query.QueryDatabase(msiPath, new[] { "Directory" }).OrderBy(s => s).ToArray(); | 68 | var directoryTable = Query.QueryDatabase(msiPath, new[] { "Directory" }).OrderBy(s => s).ToArray(); |
@@ -98,7 +98,7 @@ namespace WixToolsetTest.CoreIntegration | |||
98 | 98 | ||
99 | result.AssertSuccess(); | 99 | result.AssertSuccess(); |
100 | 100 | ||
101 | var productVersion = GetProductVersionFromMsi(msiPath); | 101 | var productVersion = GetPropertyFromMsi(msiPath, "ProductVersion"); |
102 | Assert.Equal("9.8.7.6", productVersion); | 102 | Assert.Equal("9.8.7.6", productVersion); |
103 | 103 | ||
104 | var directoryTable = Query.QueryDatabase(msiPath, new[] { "Directory" }).OrderBy(s => s).ToArray(); | 104 | var directoryTable = Query.QueryDatabase(msiPath, new[] { "Directory" }).OrderBy(s => s).ToArray(); |
@@ -112,6 +112,33 @@ namespace WixToolsetTest.CoreIntegration | |||
112 | } | 112 | } |
113 | 113 | ||
114 | [Fact] | 114 | [Fact] |
115 | public void CanBuildMsiWithOverridableBindVariable() | ||
116 | { | ||
117 | var folder = TestData.Get(@"TestData"); | ||
118 | |||
119 | using (var fs = new DisposableFileSystem()) | ||
120 | { | ||
121 | var baseFolder = fs.GetFolder(); | ||
122 | var intermediateFolder = Path.Combine(baseFolder, "obj"); | ||
123 | var msiPath = Path.Combine(baseFolder, "bin", "test1.msi"); | ||
124 | |||
125 | var result = WixRunner.Execute(new[] | ||
126 | { | ||
127 | "build", | ||
128 | Path.Combine(folder, "WixVariable", "PackageWithOverriddenBindVariable.wxs"), | ||
129 | "-bindpath", Path.Combine(folder, "SingleFile", "data"), | ||
130 | "-intermediateFolder", intermediateFolder, | ||
131 | "-o", msiPath | ||
132 | }); | ||
133 | |||
134 | result.AssertSuccess(); | ||
135 | |||
136 | var testValue = GetPropertyFromMsi(msiPath, "Test"); | ||
137 | Assert.Equal("0", testValue); | ||
138 | } | ||
139 | } | ||
140 | |||
141 | [Fact] | ||
115 | public void CanBuildBundleWithBindVariable() | 142 | public void CanBuildBundleWithBindVariable() |
116 | { | 143 | { |
117 | var folder = TestData.Get(@"TestData"); | 144 | var folder = TestData.Get(@"TestData"); |
@@ -150,7 +177,7 @@ namespace WixToolsetTest.CoreIntegration | |||
150 | 177 | ||
151 | result3.AssertSuccess(); | 178 | result3.AssertSuccess(); |
152 | 179 | ||
153 | var productVersion = GetProductVersionFromMsi(msiPath); | 180 | var productVersion = GetPropertyFromMsi(msiPath, "ProductVersion"); |
154 | WixAssert.StringEqual("255.255.65535", productVersion); | 181 | WixAssert.StringEqual("255.255.65535", productVersion); |
155 | 182 | ||
156 | var extractResult = BundleExtractor.ExtractAllContainers(null, bundlePath, Path.Combine(baseFolder, "ba"), Path.Combine(baseFolder, "attached"), Path.Combine(baseFolder, "extract")); | 183 | var extractResult = BundleExtractor.ExtractAllContainers(null, bundlePath, Path.Combine(baseFolder, "ba"), Path.Combine(baseFolder, "attached"), Path.Combine(baseFolder, "extract")); |
@@ -163,10 +190,10 @@ namespace WixToolsetTest.CoreIntegration | |||
163 | } | 190 | } |
164 | } | 191 | } |
165 | 192 | ||
166 | private static string GetProductVersionFromMsi(string msiPath) | 193 | private static string GetPropertyFromMsi(string msiPath, string propertyId) |
167 | { | 194 | { |
168 | var propertyTable = Query.QueryDatabase(msiPath, new[] { "Property" }).Select(r => r.Split('\t')).ToDictionary(r => r[0].Substring("Property:".Length), r => r[1]); | 195 | var propertyTable = Query.QueryDatabase(msiPath, new[] { "Property" }).Select(r => r.Split('\t')).ToDictionary(r => r[0].Substring("Property:".Length), r => r[1]); |
169 | Assert.True(propertyTable.TryGetValue("ProductVersion", out var productVersion)); | 196 | Assert.True(propertyTable.TryGetValue(propertyId, out var productVersion), $"Failed to find requested property: '{propertyId}'"); |
170 | 197 | ||
171 | return productVersion; | 198 | return productVersion; |
172 | } | 199 | } |