aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2021-11-30 12:35:07 -0800
committerRob Mensching <rob@firegiant.com>2021-12-03 07:48:37 -0800
commitb8024608744dc59f1dfd61c402938bcb6b4f7699 (patch)
tree8854093a75b43b710f858771cb73a52f379ec5b9 /src
parentbecc2bb059013f488d753ab51218064b3358ac91 (diff)
downloadwix-b8024608744dc59f1dfd61c402938bcb6b4f7699.tar.gz
wix-b8024608744dc59f1dfd61c402938bcb6b4f7699.tar.bz2
wix-b8024608744dc59f1dfd61c402938bcb6b4f7699.zip
Always populate bind variables for file version and language
Always populating the values (using "" for null) makes it easier to diagnose when you finally get the bind variable syntax correct. Previously, incorrect syntax and not having a value both resulted in errors.
Diffstat (limited to 'src')
-rw-r--r--src/wix/WixToolset.Core.WindowsInstaller/Bind/UpdateFileFacadesCommand.cs21
-rw-r--r--src/wix/test/WixToolsetTest.CoreIntegration/BindVariablesFixture.cs35
-rw-r--r--src/wix/test/WixToolsetTest.CoreIntegration/TestData/BindVariables/PackageWithBindVariables.wxs20
3 files changed, 61 insertions, 15 deletions
diff --git a/src/wix/WixToolset.Core.WindowsInstaller/Bind/UpdateFileFacadesCommand.cs b/src/wix/WixToolset.Core.WindowsInstaller/Bind/UpdateFileFacadesCommand.cs
index 0f77abfc..8043ffa8 100644
--- a/src/wix/WixToolset.Core.WindowsInstaller/Bind/UpdateFileFacadesCommand.cs
+++ b/src/wix/WixToolset.Core.WindowsInstaller/Bind/UpdateFileFacadesCommand.cs
@@ -195,22 +195,13 @@ namespace WixToolset.Core.WindowsInstaller.Bind
195 { 195 {
196 facade.Language = language; 196 facade.Language = language;
197 } 197 }
198 }
198 199
199 // Populate the binder variables for this file information if requested. 200 // Populate the binder variables for this file information if requested.
200 if (null != this.VariableCache) 201 if (null != this.VariableCache)
201 { 202 {
202 if (!String.IsNullOrEmpty(facade.Version)) 203 this.VariableCache[$"fileversion.{facade.Id}"] = facade.Version ?? String.Empty;
203 { 204 this.VariableCache[$"filelanguage.{facade.Id}"] = facade.Language ?? String.Empty;
204 var key = String.Format(CultureInfo.InvariantCulture, "fileversion.{0}", facade.Id);
205 this.VariableCache[key] = facade.Version;
206 }
207
208 if (!String.IsNullOrEmpty(facade.Language))
209 {
210 var key = String.Format(CultureInfo.InvariantCulture, "filelanguage.{0}", facade.Id);
211 this.VariableCache[key] = facade.Language;
212 }
213 }
214 } 205 }
215 206
216 // If this is a CLR assembly, load the assembly and get the assembly name information 207 // If this is a CLR assembly, load the assembly and get the assembly name information
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/BindVariablesFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/BindVariablesFixture.cs
index 39e6b4aa..820f1707 100644
--- a/src/wix/test/WixToolsetTest.CoreIntegration/BindVariablesFixture.cs
+++ b/src/wix/test/WixToolsetTest.CoreIntegration/BindVariablesFixture.cs
@@ -4,6 +4,7 @@ namespace WixToolsetTest.CoreIntegration
4{ 4{
5 using System; 5 using System;
6 using System.IO; 6 using System.IO;
7 using System.Linq;
7 using WixBuildTools.TestSupport; 8 using WixBuildTools.TestSupport;
8 using WixToolset.Core.TestPackage; 9 using WixToolset.Core.TestPackage;
9 using Xunit; 10 using Xunit;
@@ -39,6 +40,40 @@ namespace WixToolsetTest.CoreIntegration
39 } 40 }
40 41
41 [Fact] 42 [Fact]
43 public void CanBuildPackageWithBindVariables()
44 {
45 var folder = TestData.Get(@"TestData", "BindVariables");
46 var dotDataFolder = TestData.Get(@"TestData", ".Data");
47
48 using (var fs = new DisposableFileSystem())
49 {
50 var baseFolder = fs.GetFolder();
51 var intermediateFolder = Path.Combine(baseFolder, "obj");
52 var msiPath = Path.Combine(intermediateFolder, @"test.msi");
53
54 var result = WixRunner.Execute(new[]
55 {
56 "build",
57 Path.Combine(folder, "PackageWithBindVariables.wxs"),
58 "-intermediateFolder", intermediateFolder,
59 "-bindpath", folder,
60 "-bindpath", dotDataFolder,
61 "-o", msiPath,
62 });
63
64 result.AssertSuccess();
65
66 var queryResults = Query.QueryDatabase(msiPath, new[] { "Property" }).ToDictionary(s => s.Split('\t')[0]);
67 Assert.Equal("Property:ProductVersion\t3.14.1703.0", queryResults["Property:ProductVersion"]);
68 Assert.Equal("Property:TestPackageManufacturer\tExample Corporation", queryResults["Property:TestPackageManufacturer"]);
69 Assert.Equal("Property:TestPackageName\tPacakgeWithBindVariables", queryResults["Property:TestPackageName"]);
70 Assert.Equal("Property:TestPackageVersion\t3.14.1703.0", queryResults["Property:TestPackageVersion"]);
71 Assert.Equal("Property:TestTextVersion\tv", queryResults["Property:TestTextVersion"]);
72 Assert.False(queryResults.ContainsKey("Property:TestTextLanguage"));
73 }
74 }
75
76 [Fact]
42 public void CanBuildWithDefaultValue() 77 public void CanBuildWithDefaultValue()
43 { 78 {
44 var folder = TestData.Get(@"TestData", "BindVariables"); 79 var folder = TestData.Get(@"TestData", "BindVariables");
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/BindVariables/PackageWithBindVariables.wxs b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/BindVariables/PackageWithBindVariables.wxs
new file mode 100644
index 00000000..377f7e11
--- /dev/null
+++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/BindVariables/PackageWithBindVariables.wxs
@@ -0,0 +1,20 @@
1<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
2 <Package Name="PacakgeWithBindVariables" Version="!(bind.fileversion.TestBinaryFile)" Manufacturer="Example Corporation" UpgradeCode="00000000-0000-0000-0000-000000000000">
3
4 <Property Id="TestPackageManufacturer" Value="!(bind.Property.Manufacturer)" />
5 <Property Id="TestPackageName" Value="!(bind.Property.ProductName)" />
6 <Property Id="TestPackageVersion" Value="!(bind.Property.ProductVersion)" />
7
8 <Property Id="TestTextVersion" Value="v!(bind.fileversion.TestTextFile)" />
9 <Property Id="TestTextLangauge" Value="!(bind.filelanguage.TestTextFile)" />
10
11 <Feature Id="ProductFeature">
12 <Component Directory="ProgramFiles6432Folder" Subdirectory="test">
13 <File Id="TestBinaryFile" Source="burn.exe" />
14 </Component>
15 <Component Directory="ProgramFiles6432Folder" Subdirectory="test">
16 <File Id="TestTextFile" Source="data\test.txt" />
17 </Component>
18 </Feature>
19 </Package>
20</Wix>