aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBob Arnson <bob@firegiant.com>2025-11-16 16:38:24 -0500
committerBob Arnson <github@bobs.org>2025-11-16 17:55:10 -0500
commitc3bd9119779253dd0811e685debd42fcdf3b99c8 (patch)
treecd468f676c525f9f59990e49b9dfff008809f351 /src
parent2ce9b1c79a8fb55e123363e49dd1b3c406536278 (diff)
downloadwix-c3bd9119779253dd0811e685debd42fcdf3b99c8.tar.gz
wix-c3bd9119779253dd0811e685debd42fcdf3b99c8.tar.bz2
wix-c3bd9119779253dd0811e685debd42fcdf3b99c8.zip
Harvest relative paths relative to source file.
Ignores unnamed bind paths (sadly). Fixes https://github.com/wixtoolset/issues/issues/9097
Diffstat (limited to 'src')
-rw-r--r--src/wix/WixToolset.Core/HarvestFilesAndPayloadsCommand.cs4
-rw-r--r--src/wix/test/WixToolsetTest.CoreIntegration/HarvestFilesFixture.cs42
-rw-r--r--src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/BindPathsUnnamed.wxs19
-rw-r--r--src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/RelativeToSource.wxs6
-rw-r--r--src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/unnamedbindpath/namedfile.txt1
-rw-r--r--src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/unnamedbindpath/unnamedfile.txt1
6 files changed, 28 insertions, 45 deletions
diff --git a/src/wix/WixToolset.Core/HarvestFilesAndPayloadsCommand.cs b/src/wix/WixToolset.Core/HarvestFilesAndPayloadsCommand.cs
index 3b1b1358..b8265bc1 100644
--- a/src/wix/WixToolset.Core/HarvestFilesAndPayloadsCommand.cs
+++ b/src/wix/WixToolset.Core/HarvestFilesAndPayloadsCommand.cs
@@ -275,9 +275,7 @@ namespace WixToolset.Core
275 275
276 if (String.IsNullOrEmpty(bindName)) 276 if (String.IsNullOrEmpty(bindName))
277 { 277 {
278 var unnamedBindPath = this.Context.BindPaths.FirstOrDefault(bp => bp.Name == null)?.Path; 278 resultingDirectories.Add(path);
279
280 resultingDirectories.Add(unnamedBindPath is null ? path : Path.Combine(unnamedBindPath, path));
281 } 279 }
282 else 280 else
283 { 281 {
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/HarvestFilesFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/HarvestFilesFixture.cs
index 97f3e442..4d7253b8 100644
--- a/src/wix/test/WixToolsetTest.CoreIntegration/HarvestFilesFixture.cs
+++ b/src/wix/test/WixToolsetTest.CoreIntegration/HarvestFilesFixture.cs
@@ -24,7 +24,7 @@ namespace WixToolsetTest.CoreIntegration
24 { 24 {
25 10, 25 10,
26 }, messages); 26 }, messages);
27 }); 27 }, assertSuccess: false);
28 } 28 }
29 29
30 [Fact] 30 [Fact]
@@ -37,7 +37,7 @@ namespace WixToolsetTest.CoreIntegration
37 { 37 {
38 "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.", 38 "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.",
39 }, messages); 39 }, messages);
40 }); 40 }, assertSuccess: false);
41 } 41 }
42 42
43 [Fact] 43 [Fact]
@@ -53,7 +53,7 @@ namespace WixToolsetTest.CoreIntegration
53 @"8601: Missing directory for harvesting files: Could not find a part of the path '<sourceFolder>\files2\ThisDirectoryIsAlsoMissing'.", 53 @"8601: Missing directory for harvesting files: Could not find a part of the path '<sourceFolder>\files2\ThisDirectoryIsAlsoMissing'.",
54 @"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.", 54 @"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.",
55 }, messages); 55 }, messages);
56 }); 56 }, assertSuccess: false);
57 } 57 }
58 58
59 [Fact] 59 [Fact]
@@ -93,7 +93,7 @@ namespace WixToolsetTest.CoreIntegration
93 8602, 93 8602,
94 8602, 94 8602,
95 }, messages); 95 }, messages);
96 }); 96 }, assertSuccess: false);
97 } 97 }
98 98
99 [Fact] 99 [Fact]
@@ -109,7 +109,7 @@ namespace WixToolsetTest.CoreIntegration
109 267, 109 267,
110 267, 110 267,
111 }, messages); 111 }, messages);
112 }); 112 }, assertSuccess: false);
113 } 113 }
114 114
115 [Fact] 115 [Fact]
@@ -300,24 +300,19 @@ namespace WixToolsetTest.CoreIntegration
300 } 300 }
301 301
302 [Fact] 302 [Fact]
303 public void CanHarvestFilesWithUnnamedBindPaths() 303 public void CanHarvestFilesRelativeToSourceFile()
304 { 304 {
305 var expected = new[] 305 var expected = new[]
306 { 306 {
307 @"flsNNsTNrgmjASmTBbP.45J1F50dEc=PFiles\HarvestedFiles\test1.txt", 307 @"flsiYjLzK34LeZEChPfagEeCq391QE=PFiles\Example Corporation HarvestedFiles\BadAuthoring.wxs",
308 @"flsASLR5pHQzLmWRE.Snra7ndH7sIA=PFiles\HarvestedFiles\test2.txt", 308 @"flssFAX35joEC73c.9dGg2Cxy9yZHg=PFiles\Example Corporation HarvestedFiles\BadDirectory.wxs",
309 @"flsTZFPiMHb.qfUxdGKQYrnXOhZ.8M=PFiles\HarvestedFiles\files1_sub1\test10.txt", 309 @"flsYgiwrDUkZnBEK6iUMkxxaJlD8yQ=PFiles\Example Corporation HarvestedFiles\test1.txt",
310 @"flsLGcTTZPIU3ELiWybqnm.PQ0Ih_g=PFiles\HarvestedFiles\files1_sub1\files1_sub2\test120.txt", 310 @"flsj.cb0sFWqIPHPFSKJSEEaPDuAQ4=PFiles\Example Corporation HarvestedFiles\test2.txt",
311 @"fls1Jx2Y9Vea_.WZBH_h2e79arvDRU=PFiles\HarvestedFiles\test3.txt", 311 @"flsD7JQZm.Ts2375WMT.zsTxqCAf.s=PFiles\Example Corporation HarvestedFiles\files1_sub1\test10.txt",
312 @"flsJ9gNxWaau2X3ufphQuCV9WwAgcw=PFiles\HarvestedFiles\test4.txt", 312 @"flslrDWblm4pE.4i4jR58_XyYMmR8I=PFiles\Example Corporation HarvestedFiles\files1_sub1\files1_sub2\test120.txt",
313 @"flswcmX9dpMQytmD_5QA5aJ5szoQVA=PFiles\HarvestedFiles\files2_sub2\test20.txt",
314 @"flskKeCKFUtCYMuvw564rgPLJmyBx0=PFiles\HarvestedFiles\files2_sub2\test21.txt",
315 @"fls2agLZFnQwjoijShwT9Z0RwHyGrI=PFiles\HarvestedFiles\files2_sub3\FileName.Extension",
316 @"fls9UMOE.TOv61JuYF8IhvCKb8eous=PFiles\HarvestedFiles\namedfile.txt",
317 @"flsu53T_9CcaBegDflAImGHTajDbJ0=PFiles\HarvestedFiles\unnamedfile.txt",
318 }; 313 };
319 314
320 Build("BindPathsUnnamed.wxs", (msiPath, _) => AssertFileIdsAndTargetPaths(msiPath, expected), addUnnamedBindPaths: true); 315 Build("RelativeToSource.wxs", (msiPath, _) => AssertFileIdsAndTargetPaths(msiPath, expected), addUnnamedBindPaths: true);
321 } 316 }
322 317
323 [Fact] 318 [Fact]
@@ -423,12 +418,12 @@ namespace WixToolsetTest.CoreIntegration
423 WixAssert.CompareLineByLine(sortedExpected, actual); 418 WixAssert.CompareLineByLine(sortedExpected, actual);
424 } 419 }
425 420
426 private static void Build(string file, Action<string, WixRunnerResult> tester, bool isMsi = true, bool warningsAsErrors = true, bool addUnnamedBindPaths = false, params string[] additionalCommandLineArguments) 421 private static void Build(string file, Action<string, WixRunnerResult> tester, bool isMsi = true, bool warningsAsErrors = true, bool addUnnamedBindPaths = false, bool assertSuccess = true, params string[] additionalCommandLineArguments)
427 { 422 {
428 Build(file, (msiPath, sourceFolder, baseFolder, result) => tester(msiPath, result), isMsi, warningsAsErrors, addUnnamedBindPaths, additionalCommandLineArguments); 423 Build(file, (msiPath, sourceFolder, baseFolder, result) => tester(msiPath, result), isMsi, warningsAsErrors, addUnnamedBindPaths, assertSuccess, additionalCommandLineArguments);
429 } 424 }
430 425
431 private static void Build(string file, Action<string, string, string, WixRunnerResult> tester, bool isMsi = true, bool warningsAsErrors = true, bool addUnnamedBindPaths = false, params string[] additionalCommandLineArguments) 426 private static void Build(string file, Action<string, string, string, WixRunnerResult> tester, bool isMsi = true, bool warningsAsErrors = true, bool addUnnamedBindPaths = false, bool assertSuccess = true, params string[] additionalCommandLineArguments)
432 { 427 {
433 var sourceFolder = TestData.Get("TestData", "HarvestFiles"); 428 var sourceFolder = TestData.Get("TestData", "HarvestFiles");
434 429
@@ -465,6 +460,11 @@ namespace WixToolsetTest.CoreIntegration
465 460
466 var result = WixRunner.Execute(warningsAsErrors, arguments.ToArray()); 461 var result = WixRunner.Execute(warningsAsErrors, arguments.ToArray());
467 462
463 if (assertSuccess)
464 {
465 result.AssertSuccess();
466 }
467
468 tester(msiPath, sourceFolder, baseFolder, result); 468 tester(msiPath, sourceFolder, baseFolder, result);
469 } 469 }
470 } 470 }
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/BindPathsUnnamed.wxs b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/BindPathsUnnamed.wxs
deleted file mode 100644
index cd764926..00000000
--- a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/BindPathsUnnamed.wxs
+++ /dev/null
@@ -1,19 +0,0 @@
1<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
2 <Package Name="HarvestedFiles" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="047730a5-30fe-4a62-a520-da9381b8226a">
3 <MajorUpgrade DowngradeErrorMessage="Downgrade error message." />
4
5 <Feature Id="ProductFeature">
6 <ComponentGroupRef Id="Files" />
7 </Feature>
8
9 <ComponentGroup Id="Files" Directory="ProgramFilesFolder" Subdirectory="HarvestedFiles">
10 <Files Include="!(bindpath.ToBeHarvested)\**">
11 <Exclude Files="!(bindpath.ToBeHarvested)\notatest.txt" />
12 <Exclude Files="!(bindpath.ToBeHarvested)\**\pleasedontincludeme.dat" />
13 </Files>
14
15 <!-- Include everything from the unnamed bindpath too. -->
16 <Files Include="**" />
17 </ComponentGroup>
18 </Package>
19</Wix>
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 00000000..80dfaa6f
--- /dev/null
+++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/RelativeToSource.wxs
@@ -0,0 +1,6 @@
1<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
2 <Package Name="HarvestedFiles" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="047730a5-30fe-4a62-a520-da9381b8226a">
3 <Files Include="bad*.wxs" />
4 <Files Include=".\files1\**" />
5 </Package>
6</Wix>
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 d32727e0..00000000
--- a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/unnamedbindpath/namedfile.txt
+++ /dev/null
@@ -1 +0,0 @@
1This 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 d32727e0..00000000
--- a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/unnamedbindpath/unnamedfile.txt
+++ /dev/null
@@ -1 +0,0 @@
1This is test.txt.