diff --git a/src/wix/WixToolset.Core/HarvestFilesAndPayloadsCommand.cs b/src/wix/WixToolset.Core/HarvestFilesAndPayloadsCommand.cs index 3b1b13580..b8265bc15 100644 --- a/src/wix/WixToolset.Core/HarvestFilesAndPayloadsCommand.cs +++ b/src/wix/WixToolset.Core/HarvestFilesAndPayloadsCommand.cs @@ -275,9 +275,7 @@ private IEnumerable ResolveBindPaths(SourceLineNumber sourceLineNumbers, if (String.IsNullOrEmpty(bindName)) { - var unnamedBindPath = this.Context.BindPaths.FirstOrDefault(bp => bp.Name == null)?.Path; - - resultingDirectories.Add(unnamedBindPath is null ? path : Path.Combine(unnamedBindPath, path)); + resultingDirectories.Add(path); } else { diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/HarvestFilesFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/HarvestFilesFixture.cs index 97f3e4425..4d7253b8d 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/HarvestFilesFixture.cs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/HarvestFilesFixture.cs @@ -24,7 +24,7 @@ public void MustIncludeSomeFiles() { 10, }, messages); - }); + }, assertSuccess: false); } [Fact] @@ -37,7 +37,7 @@ public void ZeroFilesHarvestedIsAWarning() { "8600: Inclusions and exclusions resulted in zero files harvested. Unless that is expected, you should verify paths, inclusions, and exclusions on Files or Payloads for accuracy.", }, messages); - }); + }, assertSuccess: false); } [Fact] @@ -53,7 +53,7 @@ public void MissingHarvestDirectoryIsAWarning() @"8601: Missing directory for harvesting files: Could not find a part of the path '\files2\ThisDirectoryIsAlsoMissing'.", @"8600: Inclusions and exclusions resulted in zero files harvested. Unless that is expected, you should verify paths, inclusions, and exclusions on Files or Payloads for accuracy.", }, messages); - }); + }, assertSuccess: false); } [Fact] @@ -93,7 +93,7 @@ public void DuplicateFilesSomethingSomething() 8602, 8602, }, messages); - }); + }, assertSuccess: false); } [Fact] @@ -109,7 +109,7 @@ public void HarvestedFilesUnderPackageWithAuthoredFeatureAreOrphaned() 267, 267, }, messages); - }); + }, assertSuccess: false); } [Fact] @@ -300,24 +300,19 @@ public void CanHarvestFilesWithNamedBindPaths() } [Fact] - public void CanHarvestFilesWithUnnamedBindPaths() + public void CanHarvestFilesRelativeToSourceFile() { 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", + @"flsiYjLzK34LeZEChPfagEeCq391QE=PFiles\Example Corporation HarvestedFiles\BadAuthoring.wxs", + @"flssFAX35joEC73c.9dGg2Cxy9yZHg=PFiles\Example Corporation HarvestedFiles\BadDirectory.wxs", + @"flsYgiwrDUkZnBEK6iUMkxxaJlD8yQ=PFiles\Example Corporation HarvestedFiles\test1.txt", + @"flsj.cb0sFWqIPHPFSKJSEEaPDuAQ4=PFiles\Example Corporation HarvestedFiles\test2.txt", + @"flsD7JQZm.Ts2375WMT.zsTxqCAf.s=PFiles\Example Corporation HarvestedFiles\files1_sub1\test10.txt", + @"flslrDWblm4pE.4i4jR58_XyYMmR8I=PFiles\Example Corporation HarvestedFiles\files1_sub1\files1_sub2\test120.txt", }; - Build("BindPathsUnnamed.wxs", (msiPath, _) => AssertFileIdsAndTargetPaths(msiPath, expected), addUnnamedBindPaths: true); + Build("RelativeToSource.wxs", (msiPath, _) => AssertFileIdsAndTargetPaths(msiPath, expected), addUnnamedBindPaths: true); } [Fact] @@ -423,12 +418,12 @@ private static void AssertFileIdsAndTargetPaths(string msiPath, string[] expecte WixAssert.CompareLineByLine(sortedExpected, actual); } - private static void Build(string file, Action tester, bool isMsi = true, bool warningsAsErrors = true, bool addUnnamedBindPaths = false, params string[] additionalCommandLineArguments) + private static void Build(string file, Action tester, bool isMsi = true, bool warningsAsErrors = true, bool addUnnamedBindPaths = false, bool assertSuccess = true, params string[] additionalCommandLineArguments) { - Build(file, (msiPath, sourceFolder, baseFolder, result) => tester(msiPath, result), isMsi, warningsAsErrors, addUnnamedBindPaths, additionalCommandLineArguments); + Build(file, (msiPath, sourceFolder, baseFolder, result) => tester(msiPath, result), isMsi, warningsAsErrors, addUnnamedBindPaths, assertSuccess, additionalCommandLineArguments); } - private static void Build(string file, Action tester, bool isMsi = true, bool warningsAsErrors = true, bool addUnnamedBindPaths = false, params string[] additionalCommandLineArguments) + private static void Build(string file, Action tester, bool isMsi = true, bool warningsAsErrors = true, bool addUnnamedBindPaths = false, bool assertSuccess = true, params string[] additionalCommandLineArguments) { var sourceFolder = TestData.Get("TestData", "HarvestFiles"); @@ -465,6 +460,11 @@ private static void Build(string file, Action - - - - - - - - - - - - - - - - - - diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/RelativeToSource.wxs b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/RelativeToSource.wxs new file mode 100644 index 000000000..80dfaa6fa --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/RelativeToSource.wxs @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/unnamedbindpath/namedfile.txt b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/unnamedbindpath/namedfile.txt deleted file mode 100644 index d32727e04..000000000 --- a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/unnamedbindpath/namedfile.txt +++ /dev/null @@ -1 +0,0 @@ -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 deleted file mode 100644 index d32727e04..000000000 --- a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/unnamedbindpath/unnamedfile.txt +++ /dev/null @@ -1 +0,0 @@ -This is test.txt.