diff options
| author | Rob Mensching <rob@firegiant.com> | 2020-07-17 10:42:30 -0700 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2020-07-17 15:27:13 -0700 |
| commit | c37f29a156a84e27e6b38a7841e2ddcde015b071 (patch) | |
| tree | d9ff8d98970a103dcb31c1fc045d4c3031bf2a40 /src | |
| parent | 0db15d84eaabf2f1950784655ddd79413cfea44f (diff) | |
| download | wix-c37f29a156a84e27e6b38a7841e2ddcde015b071.tar.gz wix-c37f29a156a84e27e6b38a7841e2ddcde015b071.tar.bz2 wix-c37f29a156a84e27e6b38a7841e2ddcde015b071.zip | |
Fix parsing of bind variables with default values
Diffstat (limited to 'src')
5 files changed, 49 insertions, 2 deletions
diff --git a/src/WixToolset.Core/Common.cs b/src/WixToolset.Core/Common.cs index 1a748a13..6efc7571 100644 --- a/src/WixToolset.Core/Common.cs +++ b/src/WixToolset.Core/Common.cs | |||
| @@ -788,9 +788,9 @@ namespace WixToolset.Core | |||
| 788 | string scope = null; | 788 | string scope = null; |
| 789 | string defaultValue = null; | 789 | string defaultValue = null; |
| 790 | 790 | ||
| 791 | var secondDot = value.IndexOf('.', firstDot + 1, closeParen - firstDot); | ||
| 792 | var equalsDefaultValue = value.IndexOf('=', firstDot + 1, closeParen - firstDot); | 791 | var equalsDefaultValue = value.IndexOf('=', firstDot + 1, closeParen - firstDot); |
| 793 | var end = equalsDefaultValue == -1 ? closeParen : equalsDefaultValue; | 792 | var end = equalsDefaultValue == -1 ? closeParen : equalsDefaultValue; |
| 793 | var secondDot = value.IndexOf('.', firstDot + 1, end - firstDot); | ||
| 794 | 794 | ||
| 795 | if (secondDot == -1) | 795 | if (secondDot == -1) |
| 796 | { | 796 | { |
| @@ -814,7 +814,7 @@ namespace WixToolset.Core | |||
| 814 | 814 | ||
| 815 | if (equalsDefaultValue != -1 && equalsDefaultValue < closeParen) | 815 | if (equalsDefaultValue != -1 && equalsDefaultValue < closeParen) |
| 816 | { | 816 | { |
| 817 | defaultValue = value.Substring(equalsDefaultValue + 1, end - equalsDefaultValue - 1); | 817 | defaultValue = value.Substring(equalsDefaultValue + 1, closeParen - equalsDefaultValue - 1); |
| 818 | } | 818 | } |
| 819 | 819 | ||
| 820 | parsedVariable = new ParsedWixVariable | 820 | parsedVariable = new ParsedWixVariable |
diff --git a/src/test/WixToolsetTest.CoreIntegration/BindVariablesFixture.cs b/src/test/WixToolsetTest.CoreIntegration/BindVariablesFixture.cs new file mode 100644 index 00000000..3e9c7aa4 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/BindVariablesFixture.cs | |||
| @@ -0,0 +1,38 @@ | |||
| 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; | ||
| 6 | using System.IO; | ||
| 7 | using WixBuildTools.TestSupport; | ||
| 8 | using WixToolset.Core.TestPackage; | ||
| 9 | using Xunit; | ||
| 10 | |||
| 11 | public class BindVariablesFixture | ||
| 12 | { | ||
| 13 | [Fact] | ||
| 14 | public void CanBuildWithDefaultValue() | ||
| 15 | { | ||
| 16 | var folder = TestData.Get(@"TestData\BindVariables"); | ||
| 17 | |||
| 18 | using (var fs = new DisposableFileSystem()) | ||
| 19 | { | ||
| 20 | var baseFolder = fs.GetFolder(); | ||
| 21 | var intermediateFolder = Path.Combine(baseFolder, "obj"); | ||
| 22 | var wixlibPath = Path.Combine(intermediateFolder, @"test.wixlib"); | ||
| 23 | |||
| 24 | var result = WixRunner.Execute(new[] | ||
| 25 | { | ||
| 26 | "build", | ||
| 27 | Path.Combine(folder, "DefaultedVariable.wxs"), | ||
| 28 | "-bf", | ||
| 29 | "-intermediateFolder", intermediateFolder, | ||
| 30 | "-bindpath", folder, | ||
| 31 | "-o", wixlibPath, | ||
| 32 | }); | ||
| 33 | |||
| 34 | result.AssertSuccess(); | ||
| 35 | } | ||
| 36 | } | ||
| 37 | } | ||
| 38 | } | ||
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/BindVariables/DefaultedVariable.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/BindVariables/DefaultedVariable.wxs new file mode 100644 index 00000000..c3528a67 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/BindVariables/DefaultedVariable.wxs | |||
| @@ -0,0 +1,6 @@ | |||
| 1 | <?xml version="1.0" encoding="utf-8" ?> | ||
| 2 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> | ||
| 3 | <Fragment> | ||
| 4 | <Binary Id="Bound" SourceFile="!(wix.Test=data\test.txt)" /> | ||
| 5 | </Fragment> | ||
| 6 | </Wix> | ||
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/BindVariables/data/test.txt b/src/test/WixToolsetTest.CoreIntegration/TestData/BindVariables/data/test.txt new file mode 100644 index 00000000..3b862323 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/BindVariables/data/test.txt | |||
| @@ -0,0 +1 @@ | |||
| This is test.txt | |||
diff --git a/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj b/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj index 87ace0b9..15078b8a 100644 --- a/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj +++ b/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj | |||
| @@ -23,6 +23,8 @@ | |||
| 23 | <Content Include="TestData\AppSearch\RegistrySearch.wxs" CopyToOutputDirectory="PreserveNewest" /> | 23 | <Content Include="TestData\AppSearch\RegistrySearch.wxs" CopyToOutputDirectory="PreserveNewest" /> |
| 24 | <Content Include="TestData\BadEnsureTable\BadEnsureTable.wxs" CopyToOutputDirectory="PreserveNewest" /> | 24 | <Content Include="TestData\BadEnsureTable\BadEnsureTable.wxs" CopyToOutputDirectory="PreserveNewest" /> |
| 25 | <Content Include="TestData\BadInput\RegistryKey.wxs" CopyToOutputDirectory="PreserveNewest" /> | 25 | <Content Include="TestData\BadInput\RegistryKey.wxs" CopyToOutputDirectory="PreserveNewest" /> |
| 26 | <Content Include="TestData\BindVariables\DefaultedVariable.wxs" CopyToOutputDirectory="PreserveNewest" /> | ||
| 27 | <Content Include="TestData\BindVariables\data\test.txt" CopyToOutputDirectory="PreserveNewest" /> | ||
| 26 | <Content Include="TestData\BundleCustomTable\BundleCustomTable.wxs" CopyToOutputDirectory="PreserveNewest" /> | 28 | <Content Include="TestData\BundleCustomTable\BundleCustomTable.wxs" CopyToOutputDirectory="PreserveNewest" /> |
| 27 | <Content Include="TestData\BundleExtension\BundleExtension.wxs" CopyToOutputDirectory="PreserveNewest" /> | 29 | <Content Include="TestData\BundleExtension\BundleExtension.wxs" CopyToOutputDirectory="PreserveNewest" /> |
| 28 | <Content Include="TestData\BundleExtension\BundleExtensionSearches.wxs" CopyToOutputDirectory="PreserveNewest" /> | 30 | <Content Include="TestData\BundleExtension\BundleExtensionSearches.wxs" CopyToOutputDirectory="PreserveNewest" /> |
