diff options
| author | Sean Hall <r.sean.hall@gmail.com> | 2018-09-09 15:15:17 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-09-09 15:15:17 -0500 |
| commit | 954b7179a06c1933ae783b602bc29caa0370aec0 (patch) | |
| tree | 98584897bded70665994d9fe68f5e0f1bd24dfb4 /src | |
| parent | 38b6fe65e36ed9442e3fc714dea1793d457f0b20 (diff) | |
| parent | a2614e6e11108abba52b9eca8f460d9ab57513f5 (diff) | |
| download | wix-954b7179a06c1933ae783b602bc29caa0370aec0.tar.gz wix-954b7179a06c1933ae783b602bc29caa0370aec0.tar.bz2 wix-954b7179a06c1933ae783b602bc29caa0370aec0.zip | |
Merge pull request #2 from wixtoolset/bob/5853-variable-redefinition
Warn on variable redefinition only when the values are different.
Diffstat (limited to 'src')
7 files changed, 99 insertions, 1 deletions
diff --git a/src/WixToolset.Core/ExtensibilityServices/PreprocessHelper.cs b/src/WixToolset.Core/ExtensibilityServices/PreprocessHelper.cs index 0e4bba51..562f094f 100644 --- a/src/WixToolset.Core/ExtensibilityServices/PreprocessHelper.cs +++ b/src/WixToolset.Core/ExtensibilityServices/PreprocessHelper.cs | |||
| @@ -45,7 +45,7 @@ namespace WixToolset.Core.ExtensibilityServices | |||
| 45 | } | 45 | } |
| 46 | else | 46 | else |
| 47 | { | 47 | { |
| 48 | if (showWarning) | 48 | if (showWarning && value != currentValue) |
| 49 | { | 49 | { |
| 50 | this.Messaging.Write(WarningMessages.VariableDeclarationCollision(context.CurrentSourceLineNumber, name, value, currentValue)); | 50 | this.Messaging.Write(WarningMessages.VariableDeclarationCollision(context.CurrentSourceLineNumber, name, value, currentValue)); |
| 51 | } | 51 | } |
diff --git a/src/test/WixToolsetTest.CoreIntegration/PreprocessorFixture.cs b/src/test/WixToolsetTest.CoreIntegration/PreprocessorFixture.cs new file mode 100644 index 00000000..1193b685 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/PreprocessorFixture.cs | |||
| @@ -0,0 +1,44 @@ | |||
| 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | ||
| 2 | |||
| 3 | namespace WixToolsetTest.CoreIntegration | ||
| 4 | { | ||
| 5 | using System.IO; | ||
| 6 | using System.Linq; | ||
| 7 | using WixBuildTools.TestSupport; | ||
| 8 | using WixToolset.Core.TestPackage; | ||
| 9 | using WixToolset.Data; | ||
| 10 | using WixToolset.Data.Tuples; | ||
| 11 | using WixToolset.Data.WindowsInstaller; | ||
| 12 | using Xunit; | ||
| 13 | |||
| 14 | public class PreprocessorFixture | ||
| 15 | { | ||
| 16 | [Fact] | ||
| 17 | public void VariableRedefinitionIsAWarning() | ||
| 18 | { | ||
| 19 | var folder = TestData.Get(@"TestData\Variables"); | ||
| 20 | |||
| 21 | using (var fs = new DisposableFileSystem()) | ||
| 22 | { | ||
| 23 | var baseFolder = fs.GetFolder(); | ||
| 24 | var intermediateFolder = Path.Combine(baseFolder, "obj"); | ||
| 25 | |||
| 26 | var result = WixRunner.Execute(new[] | ||
| 27 | { | ||
| 28 | "build", | ||
| 29 | Path.Combine(folder, "Package.wxs"), | ||
| 30 | Path.Combine(folder, "PackageComponents.wxs"), | ||
| 31 | "-loc", Path.Combine(folder, "Package.en-us.wxl"), | ||
| 32 | "-bindpath", Path.Combine(folder, "data"), | ||
| 33 | "-intermediateFolder", intermediateFolder, | ||
| 34 | "-o", Path.Combine(baseFolder, @"bin\test.msi") | ||
| 35 | }, out var messages); | ||
| 36 | Assert.Equal(0, result); | ||
| 37 | |||
| 38 | var warnings = messages.Where(message => message.Id == 1118); | ||
| 39 | Assert.Single(warnings); | ||
| 40 | } | ||
| 41 | } | ||
| 42 | } | ||
| 43 | } | ||
| 44 | |||
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/Variables/Package.en-us.wxl b/src/test/WixToolsetTest.CoreIntegration/TestData/Variables/Package.en-us.wxl new file mode 100644 index 00000000..38c12ac1 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/Variables/Package.en-us.wxl | |||
| @@ -0,0 +1,11 @@ | |||
| 1 | <?xml version="1.0" encoding="utf-8"?> | ||
| 2 | |||
| 3 | <!-- | ||
| 4 | This file contains the declaration of all the localizable strings. | ||
| 5 | --> | ||
| 6 | <WixLocalization xmlns="http://wixtoolset.org/schemas/v4/wxl" Culture="en-US"> | ||
| 7 | |||
| 8 | <String Id="DowngradeError">A newer version of [ProductName] is already installed.</String> | ||
| 9 | <String Id="FeatureTitle">MsiPackage</String> | ||
| 10 | |||
| 11 | </WixLocalization> | ||
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/Variables/Package.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/Variables/Package.wxs new file mode 100644 index 00000000..896b7e3f --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/Variables/Package.wxs | |||
| @@ -0,0 +1,28 @@ | |||
| 1 | <?xml version="1.0" encoding="utf-8"?> | ||
| 2 | |||
| 3 | <?define Foo = "Foo" ?> | ||
| 4 | <?define Foo = "Foo" ?> | ||
| 5 | |||
| 6 | <?define Bar = "Bar" ?> | ||
| 7 | <?define Bar = "Baz" ?> | ||
| 8 | |||
| 9 | <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"> | ||
| 11 | <Package InstallerVersion="200" Compressed="no" InstallScope="perMachine" /> | ||
| 12 | |||
| 13 | <MajorUpgrade DowngradeErrorMessage="!(loc.DowngradeError)" /> | ||
| 14 | <MediaTemplate /> | ||
| 15 | |||
| 16 | <Feature Id="ProductFeature" Title="!(loc.FeatureTitle)"> | ||
| 17 | <ComponentGroupRef Id="ProductComponents" /> | ||
| 18 | </Feature> | ||
| 19 | </Product> | ||
| 20 | |||
| 21 | <Fragment> | ||
| 22 | <Directory Id="TARGETDIR" Name="SourceDir"> | ||
| 23 | <Directory Id="ProgramFilesFolder"> | ||
| 24 | <Directory Id="INSTALLFOLDER" Name="MsiPackage" /> | ||
| 25 | </Directory> | ||
| 26 | </Directory> | ||
| 27 | </Fragment> | ||
| 28 | </Wix> | ||
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/Variables/PackageComponents.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/Variables/PackageComponents.wxs new file mode 100644 index 00000000..e26c4509 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/Variables/PackageComponents.wxs | |||
| @@ -0,0 +1,10 @@ | |||
| 1 | <?xml version="1.0" encoding="utf-8"?> | ||
| 2 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> | ||
| 3 | <Fragment> | ||
| 4 | <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER"> | ||
| 5 | <Component> | ||
| 6 | <File Source="test.txt" /> | ||
| 7 | </Component> | ||
| 8 | </ComponentGroup> | ||
| 9 | </Fragment> | ||
| 10 | </Wix> | ||
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/Variables/data/test.txt b/src/test/WixToolsetTest.CoreIntegration/TestData/Variables/data/test.txt new file mode 100644 index 00000000..cd0db0e1 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/Variables/data/test.txt | |||
| @@ -0,0 +1 @@ | |||
| This is test.txt. \ No newline at end of file | |||
diff --git a/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj b/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj index 516bd95c..f52d368b 100644 --- a/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj +++ b/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj | |||
| @@ -49,6 +49,10 @@ | |||
| 49 | <Content Include="TestData\Assembly\Package.en-us.wxl" CopyToOutputDirectory="PreserveNewest" /> | 49 | <Content Include="TestData\Assembly\Package.en-us.wxl" CopyToOutputDirectory="PreserveNewest" /> |
| 50 | <Content Include="TestData\Assembly\Package.wxs" CopyToOutputDirectory="PreserveNewest" /> | 50 | <Content Include="TestData\Assembly\Package.wxs" CopyToOutputDirectory="PreserveNewest" /> |
| 51 | <Content Include="TestData\Assembly\PackageComponents.wxs" CopyToOutputDirectory="PreserveNewest" /> | 51 | <Content Include="TestData\Assembly\PackageComponents.wxs" CopyToOutputDirectory="PreserveNewest" /> |
| 52 | <Content Include="TestData\Variables\data\test.txt" CopyToOutputDirectory="PreserveNewest" /> | ||
| 53 | <Content Include="TestData\Variables\Package.en-us.wxl" CopyToOutputDirectory="PreserveNewest" /> | ||
| 54 | <Content Include="TestData\Variables\Package.wxs" CopyToOutputDirectory="PreserveNewest" /> | ||
| 55 | <Content Include="TestData\Variables\PackageComponents.wxs" CopyToOutputDirectory="PreserveNewest" /> | ||
| 52 | </ItemGroup> | 56 | </ItemGroup> |
| 53 | 57 | ||
| 54 | <ItemGroup> | 58 | <ItemGroup> |
