From 58cd3477c3ae3d7880991ee1651a862a45371e08 Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Wed, 6 Nov 2019 18:17:18 -0500 Subject: Add preprocessor variables with WiX version info. $(sys.WIXMAJORVERSION) $(sys.WIXVERSION) --- .../ExtensibilityServices/PreprocessHelper.cs | 6 ++++ .../PreprocessorFixture.cs | 33 ++++++++++++++++++++-- .../TestData/Variables/Package.wxs | 4 +++ 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 throw new ArgumentException("Unknown platform enumeration '{0}' encountered.", context.Platform.ToString()); } + case "WIXMAJORVERSION": + return ThisAssembly.AssemblyFileVersion.Split('.')[0]; + + case "WIXVERSION": + return ThisAssembly.AssemblyFileVersion; + default: return null; } 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 using WixBuildTools.TestSupport; using WixToolset.Core; using WixToolset.Core.TestPackage; + using WixToolset.Data; using WixToolset.Extensibility.Data; using Xunit; @@ -61,8 +62,36 @@ namespace WixToolsetTest.CoreIntegration result.AssertSuccess(); - var warnings = result.Messages.Where(message => message.Id == 1118); - Assert.Single(warnings); + var warning = result.Messages.Where(message => message.Id == (int)WarningMessages.Ids.VariableDeclarationCollision); + Assert.Single(warning); + } + } + + [Fact] + public void WixVersionVariablesWork() + { + var folder = TestData.Get(@"TestData\Variables"); + + using (var fs = new DisposableFileSystem()) + { + var baseFolder = fs.GetFolder(); + var intermediateFolder = Path.Combine(baseFolder, "obj"); + + var result = WixRunner.Execute(new[] + { + "build", + Path.Combine(folder, "Package.wxs"), + Path.Combine(folder, "PackageComponents.wxs"), + "-loc", Path.Combine(folder, "Package.en-us.wxl"), + "-bindpath", Path.Combine(folder, "data"), + "-intermediateFolder", intermediateFolder, + "-o", Path.Combine(baseFolder, @"bin\test.msi") + }); + + result.AssertSuccess(); + + var warning = result.Messages.Where(message => message.Id == (int)WarningMessages.Ids.PreprocessorWarning); + Assert.Single(warning); } } 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 @@ += 4 AND $(sys.WIXMAJORVERSION) < 5 ?> + + + -- cgit v1.2.3-55-g6feb