From 94b3c44ea27e29253a26e18bf0c70295d0fc48e5 Mon Sep 17 00:00:00 2001 From: Bob Arnson <bob@firegiant.com> Date: Thu, 14 Nov 2019 18:10:00 -0500 Subject: Fix EnvironmentTuple nullable fields. Add test. --- src/WixToolset.Core/Compiler.cs | 2 +- .../MsiQueryFixture.cs | 44 ++++++++++++++++++++++ .../TestData/Environment/Environment.wxs | 13 +++++++ .../WixToolsetTest.CoreIntegration.csproj | 1 + 4 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 src/test/WixToolsetTest.CoreIntegration/TestData/Environment/Environment.wxs (limited to 'src') diff --git a/src/WixToolset.Core/Compiler.cs b/src/WixToolset.Core/Compiler.cs index 56d3a8b4..179c5a37 100644 --- a/src/WixToolset.Core/Compiler.cs +++ b/src/WixToolset.Core/Compiler.cs @@ -5203,7 +5203,7 @@ namespace WixToolset.Core this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Name")); } - if (!part.HasValue && action == EnvironmentActionType.Create) + if (part.HasValue && action == EnvironmentActionType.Create) { this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttribute(sourceLineNumbers, node.Name.LocalName, "Part", "Action", "create")); } diff --git a/src/test/WixToolsetTest.CoreIntegration/MsiQueryFixture.cs b/src/test/WixToolsetTest.CoreIntegration/MsiQueryFixture.cs index 81f780dc..068ae2b7 100644 --- a/src/test/WixToolsetTest.CoreIntegration/MsiQueryFixture.cs +++ b/src/test/WixToolsetTest.CoreIntegration/MsiQueryFixture.cs @@ -427,6 +427,41 @@ namespace WixToolsetTest.CoreIntegration } } + [Fact] + public void PopulatesEnvironmentTable() + { + var folder = TestData.Get(@"TestData"); + + using (var fs = new DisposableFileSystem()) + { + var baseFolder = fs.GetFolder(); + var intermediateFolder = Path.Combine(baseFolder, "obj"); + var msiPath = Path.Combine(baseFolder, @"bin\test.msi"); + + var result = WixRunner.Execute(new[] + { + "build", + Path.Combine(folder, "Environment", "Environment.wxs"), + Path.Combine(folder, "ProductWithComponentGroupRef", "Product.wxs"), + "-bindpath", Path.Combine(folder, "SingleFile", "data"), + "-intermediateFolder", intermediateFolder, + "-o", msiPath + }); + + result.AssertSuccess(); + + Assert.True(File.Exists(msiPath)); + var results = Query.QueryDatabase(msiPath, new[] { "Environment" }); + Assert.Equal(new[] + { + "Environment:WixEnvironmentTest1\t=-WixEnvTest1\t\tWixEnvironmentTest", + "Environment:WixEnvironmentTest2\t+-WixEnvTest1\t\tWixEnvironmentTest", + "Environment:WixEnvironmentTest3\t!-WixEnvTest1\t\tWixEnvironmentTest", + "Environment:WixEnvironmentTest4\t=-*WIX\t[INSTALLFOLDER]\tWixEnvironmentTest", + }, results); + } + } + [Fact] public void PopulatesFeatureTableWithParent() { @@ -942,6 +977,15 @@ namespace WixToolsetTest.CoreIntegration "Upgrade:{12E4699F-E774-4D05-8A01-5BDD41BBA127}\t1.0.0.0\t\t1033\t2\t\tWIX_DOWNGRADE_DETECTED", "Upgrade:{B05772EA-82B8-4DE0-B7EB-45B5F0CCFE6D}\t1.0.0\t\t\t256\t\tRELPRODFOUND", }, results); + + var prefix = "Property:SecureCustomProperties\t"; + var secureProperties = Query.QueryDatabase(msiPath, new[] { "Property" }).Where(p => p.StartsWith(prefix)).Single(); + Assert.Equal(new[] + { + "RELPRODFOUND", + "WIX_DOWNGRADE_DETECTED", + "WIX_UPGRADE_DETECTED", + }, secureProperties.Substring(prefix.Length).Split(';').OrderBy(p => p)); } } } diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/Environment/Environment.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/Environment/Environment.wxs new file mode 100644 index 00000000..284801e2 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/Environment/Environment.wxs @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> +<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> + <Fragment> + <ComponentGroup Id="ProductComponents"> + <Component Id="WixEnvironmentTest" Guid="{068C1CF4-DA54-4221-B0D2-E7310770DF0B}" Directory="INSTALLFOLDER"> + <Environment Id="WixEnvironmentTest1" Action="set" Name="WixEnvTest1"/> + <Environment Id="WixEnvironmentTest2" Action="create" Name="WixEnvTest1"/> + <Environment Id="WixEnvironmentTest3" Action="remove" Name="WixEnvTest1"/> + <Environment Id="WixEnvironmentTest4" Name="WIX" Action="set" System="yes" Value="[INSTALLFOLDER]" /> + </Component> + </ComponentGroup> + </Fragment> +</Wix> diff --git a/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj b/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj index 75a55c31..0330adf6 100644 --- a/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj +++ b/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj @@ -31,6 +31,7 @@ <Content Include="TestData\DialogsInInstallUISequence\Package.en-us.wxl" CopyToOutputDirectory="PreserveNewest" /> <Content Include="TestData\DialogsInInstallUISequence\Package.wxs" CopyToOutputDirectory="PreserveNewest" /> <Content Include="TestData\DialogsInInstallUISequence\PackageComponents.wxs" CopyToOutputDirectory="PreserveNewest" /> + <Content Include="TestData\Environment\Environment.wxs" CopyToOutputDirectory="PreserveNewest" /> <Content Include="TestData\ErrorsInUI\data\test.txt" CopyToOutputDirectory="PreserveNewest" /> <Content Include="TestData\ErrorsInUI\Package.en-us.wxl" CopyToOutputDirectory="PreserveNewest" /> <Content Include="TestData\ErrorsInUI\Package.wxs" CopyToOutputDirectory="PreserveNewest" /> -- cgit v1.2.3-55-g6feb