diff --git a/src/wix/WixToolset.Core/ExtensibilityServices/FileResolver.cs b/src/wix/WixToolset.Core/ExtensibilityServices/FileResolver.cs index 8f08e75e4..c4f212c91 100644 --- a/src/wix/WixToolset.Core/ExtensibilityServices/FileResolver.cs +++ b/src/wix/WixToolset.Core/ExtensibilityServices/FileResolver.cs @@ -90,7 +90,7 @@ private string MustResolveUsingBindPaths(string source, IntermediateSymbolDefini if (-1 != closeParen) { bindName = source.Substring(BindPathOpenString.Length, closeParen - BindPathOpenString.Length); - path = source.Substring(BindPathOpenString.Length + bindName.Length + 1); // +1 for the closing brace. + path = source.Substring(BindPathOpenString.Length + bindName.Length + 1); // +1 for the closing paren. path = path.TrimStart('\\'); // remove starting '\\' char so the path doesn't look rooted. } } diff --git a/src/wix/WixToolset.Core/HarvestFilesCommand.cs b/src/wix/WixToolset.Core/HarvestFilesCommand.cs index a8c716d04..6209c6b32 100644 --- a/src/wix/WixToolset.Core/HarvestFilesCommand.cs +++ b/src/wix/WixToolset.Core/HarvestFilesCommand.cs @@ -199,14 +199,16 @@ private IEnumerable ResolveBindPaths(SourceLineNumber sourceLineNumbers, if (-1 != closeParen) { bindName = source.Substring(BindPathOpenString.Length, closeParen - BindPathOpenString.Length); - path = source.Substring(BindPathOpenString.Length + bindName.Length + 1); // +1 for the closing brace. + path = source.Substring(BindPathOpenString.Length + bindName.Length + 1); // +1 for the closing paren. path = path.TrimStart('\\'); // remove starting '\\' char so the path doesn't look rooted. } } if (String.IsNullOrEmpty(bindName)) { - resultingDirectories.Add(path); + var unnamedBindPath = this.Context.BindPaths.SingleOrDefault(bp => bp.Name == null)?.Path; + + resultingDirectories.Add(unnamedBindPath is null ? path : Path.Combine(unnamedBindPath, path)); } else { diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/HarvestFilesFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/HarvestFilesFixture.cs index 7da47f6b3..e8d545c88 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/HarvestFilesFixture.cs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/HarvestFilesFixture.cs @@ -236,7 +236,7 @@ public void CanHarvestFilesInModules() } [Fact] - public void CanHarvestFilesWithBindPaths() + public void CanHarvestFilesWithNamedBindPaths() { var expected = new[] { @@ -254,6 +254,27 @@ public void CanHarvestFilesWithBindPaths() Build("BindPaths.wxs", (msiPath, _) => AssertFileIdsAndTargetPaths(msiPath, expected)); } + [Fact] + public void CanHarvestFilesWithUnnamedBindPaths() + { + var expected = new[] + { + @"flsNNsTNrgmjASmTBbP.45J1F50dEc=PFiles\HarvestedFiles\test1.txt", + @"flsASLR5pHQzLmWRE.Snra7ndH7sIA=PFiles\HarvestedFiles\test2.txt", + @"flsTZFPiMHb.qfUxdGKQYrnXOhZ.8M=PFiles\HarvestedFiles\files1_sub1\test10.txt", + @"flsLGcTTZPIU3ELiWybqnm.PQ0Ih_g=PFiles\HarvestedFiles\files1_sub1\files1_sub2\test120.txt", + @"fls1Jx2Y9Vea_.WZBH_h2e79arvDRU=PFiles\HarvestedFiles\test3.txt", + @"flsJ9gNxWaau2X3ufphQuCV9WwAgcw=PFiles\HarvestedFiles\test4.txt", + @"flswcmX9dpMQytmD_5QA5aJ5szoQVA=PFiles\HarvestedFiles\files2_sub2\test20.txt", + @"flskKeCKFUtCYMuvw564rgPLJmyBx0=PFiles\HarvestedFiles\files2_sub2\test21.txt", + @"fls2agLZFnQwjoijShwT9Z0RwHyGrI=PFiles\HarvestedFiles\files2_sub3\FileName.Extension", + @"fls9UMOE.TOv61JuYF8IhvCKb8eous=PFiles\HarvestedFiles\namedfile.txt", + @"flsu53T_9CcaBegDflAImGHTajDbJ0=PFiles\HarvestedFiles\unnamedfile.txt", + }; + + Build("BindPathsUnnamed.wxs", (msiPath, _) => AssertFileIdsAndTargetPaths(msiPath, expected), addUnnamedBindPath: true); + } + [Fact] public void CanHarvestFilesInStandardDirectory() { @@ -319,7 +340,7 @@ private static void AssertFileIdsAndTargetPaths(string msiPath, string[] expecte Assert.Equal(sortedExpected, actual); } - private static void Build(string file, Action tester, bool isPackage = true, params string[] additionalCommandLineArguments) + private static void Build(string file, Action tester, bool isPackage = true, bool addUnnamedBindPath = false, params string[] additionalCommandLineArguments) { var folder = TestData.Get("TestData", "HarvestFiles"); @@ -335,12 +356,17 @@ private static void Build(string file, Action tester, b "build", Path.Combine(folder, file), "-intermediateFolder", intermediateFolder, - "-bindpath", folder, "-bindpath", @$"ToBeHarvested={folder}\files1", "-bindpath", @$"ToBeHarvested={folder}\files2", "-o", msiPath, }; + if (addUnnamedBindPath) + { + arguments.Add("-bindpath"); + arguments.Add(Path.Combine(folder, "unnamedbindpath")); + } + if (additionalCommandLineArguments.Length > 0) { arguments.AddRange(additionalCommandLineArguments); diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/BindPathsUnnamed.wxs b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/BindPathsUnnamed.wxs new file mode 100644 index 000000000..cd764926c --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/BindPathsUnnamed.wxs @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/unnamedbindpath/namedfile.txt b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/unnamedbindpath/namedfile.txt new file mode 100644 index 000000000..d32727e04 --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/unnamedbindpath/namedfile.txt @@ -0,0 +1 @@ +This is test.txt. diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/unnamedbindpath/unnamedfile.txt b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/unnamedbindpath/unnamedfile.txt new file mode 100644 index 000000000..d32727e04 --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/unnamedbindpath/unnamedfile.txt @@ -0,0 +1 @@ +This is test.txt.