aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBob Arnson <bob@firegiant.com>2019-11-06 18:17:18 -0500
committerBob Arnson <bob@firegiant.com>2019-11-06 19:13:38 -0500
commit58cd3477c3ae3d7880991ee1651a862a45371e08 (patch)
tree933c6b44723e6d2d41208a5904b964fe91bf68c3 /src
parent97a70bbc1b90cb26f8c77d83e703689d15d08761 (diff)
downloadwix-58cd3477c3ae3d7880991ee1651a862a45371e08.tar.gz
wix-58cd3477c3ae3d7880991ee1651a862a45371e08.tar.bz2
wix-58cd3477c3ae3d7880991ee1651a862a45371e08.zip
Add preprocessor variables with WiX version info.
$(sys.WIXMAJORVERSION) $(sys.WIXVERSION)
Diffstat (limited to 'src')
-rw-r--r--src/WixToolset.Core/ExtensibilityServices/PreprocessHelper.cs6
-rw-r--r--src/test/WixToolsetTest.CoreIntegration/PreprocessorFixture.cs33
-rw-r--r--src/test/WixToolsetTest.CoreIntegration/TestData/Variables/Package.wxs4
3 files changed, 41 insertions, 2 deletions
diff --git a/src/WixToolset.Core/ExtensibilityServices/PreprocessHelper.cs b/src/WixToolset.Core/ExtensibilityServices/PreprocessHelper.cs
index dfee0046..60726a02 100644
--- a/src/WixToolset.Core/ExtensibilityServices/PreprocessHelper.cs
+++ b/src/WixToolset.Core/ExtensibilityServices/PreprocessHelper.cs
@@ -248,6 +248,12 @@ namespace WixToolset.Core.ExtensibilityServices
248 throw new ArgumentException("Unknown platform enumeration '{0}' encountered.", context.Platform.ToString()); 248 throw new ArgumentException("Unknown platform enumeration '{0}' encountered.", context.Platform.ToString());
249 } 249 }
250 250
251 case "WIXMAJORVERSION":
252 return ThisAssembly.AssemblyFileVersion.Split('.')[0];
253
254 case "WIXVERSION":
255 return ThisAssembly.AssemblyFileVersion;
256
251 default: 257 default:
252 return null; 258 return null;
253 } 259 }
diff --git a/src/test/WixToolsetTest.CoreIntegration/PreprocessorFixture.cs b/src/test/WixToolsetTest.CoreIntegration/PreprocessorFixture.cs
index 633a1b46..4e48cbe1 100644
--- a/src/test/WixToolsetTest.CoreIntegration/PreprocessorFixture.cs
+++ b/src/test/WixToolsetTest.CoreIntegration/PreprocessorFixture.cs
@@ -7,6 +7,7 @@ namespace WixToolsetTest.CoreIntegration
7 using WixBuildTools.TestSupport; 7 using WixBuildTools.TestSupport;
8 using WixToolset.Core; 8 using WixToolset.Core;
9 using WixToolset.Core.TestPackage; 9 using WixToolset.Core.TestPackage;
10 using WixToolset.Data;
10 using WixToolset.Extensibility.Data; 11 using WixToolset.Extensibility.Data;
11 using Xunit; 12 using Xunit;
12 13
@@ -61,8 +62,36 @@ namespace WixToolsetTest.CoreIntegration
61 62
62 result.AssertSuccess(); 63 result.AssertSuccess();
63 64
64 var warnings = result.Messages.Where(message => message.Id == 1118); 65 var warning = result.Messages.Where(message => message.Id == (int)WarningMessages.Ids.VariableDeclarationCollision);
65 Assert.Single(warnings); 66 Assert.Single(warning);
67 }
68 }
69
70 [Fact]
71 public void WixVersionVariablesWork()
72 {
73 var folder = TestData.Get(@"TestData\Variables");
74
75 using (var fs = new DisposableFileSystem())
76 {
77 var baseFolder = fs.GetFolder();
78 var intermediateFolder = Path.Combine(baseFolder, "obj");
79
80 var result = WixRunner.Execute(new[]
81 {
82 "build",
83 Path.Combine(folder, "Package.wxs"),
84 Path.Combine(folder, "PackageComponents.wxs"),
85 "-loc", Path.Combine(folder, "Package.en-us.wxl"),
86 "-bindpath", Path.Combine(folder, "data"),
87 "-intermediateFolder", intermediateFolder,
88 "-o", Path.Combine(baseFolder, @"bin\test.msi")
89 });
90
91 result.AssertSuccess();
92
93 var warning = result.Messages.Where(message => message.Id == (int)WarningMessages.Ids.PreprocessorWarning);
94 Assert.Single(warning);
66 } 95 }
67 } 96 }
68 97
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/Variables/Package.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/Variables/Package.wxs
index 896b7e3f..9f5e3f34 100644
--- a/src/test/WixToolsetTest.CoreIntegration/TestData/Variables/Package.wxs
+++ b/src/test/WixToolsetTest.CoreIntegration/TestData/Variables/Package.wxs
@@ -6,6 +6,10 @@
6<?define Bar = "Bar" ?> 6<?define Bar = "Bar" ?>
7<?define Bar = "Baz" ?> 7<?define Bar = "Baz" ?>
8 8
9<?if $(sys.WIXMAJORVERSION) >= 4 AND $(sys.WIXMAJORVERSION) < 5 ?>
10 <?warning WiX v4 is in effect! ?>
11<?endif?>
12
9<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> 13<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
10 <Product Id="*" Name="MsiPackage" Language="1033" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="047730a5-30fe-4a62-a520-da9381b8226a"> 14 <Product Id="*" Name="MsiPackage" Language="1033" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="047730a5-30fe-4a62-a520-da9381b8226a">
11 <Package InstallerVersion="200" Compressed="no" InstallScope="perMachine" /> 15 <Package InstallerVersion="200" Compressed="no" InstallScope="perMachine" />