Skip to content

Commit c3bd911

Browse files
committed
Harvest relative paths relative to source file.
Ignores unnamed bind paths (sadly). Fixes wixtoolset/issues#9097
1 parent 2ce9b1c commit c3bd911

File tree

6 files changed

+28
-45
lines changed

6 files changed

+28
-45
lines changed

src/wix/WixToolset.Core/HarvestFilesAndPayloadsCommand.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,7 @@ private IEnumerable<string> ResolveBindPaths(SourceLineNumber sourceLineNumbers,
275275

276276
if (String.IsNullOrEmpty(bindName))
277277
{
278-
var unnamedBindPath = this.Context.BindPaths.FirstOrDefault(bp => bp.Name == null)?.Path;
279-
280-
resultingDirectories.Add(unnamedBindPath is null ? path : Path.Combine(unnamedBindPath, path));
278+
resultingDirectories.Add(path);
281279
}
282280
else
283281
{

src/wix/test/WixToolsetTest.CoreIntegration/HarvestFilesFixture.cs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public void MustIncludeSomeFiles()
2424
{
2525
10,
2626
}, messages);
27-
});
27+
}, assertSuccess: false);
2828
}
2929

3030
[Fact]
@@ -37,7 +37,7 @@ public void ZeroFilesHarvestedIsAWarning()
3737
{
3838
"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.",
3939
}, messages);
40-
});
40+
}, assertSuccess: false);
4141
}
4242

4343
[Fact]
@@ -53,7 +53,7 @@ public void MissingHarvestDirectoryIsAWarning()
5353
@"8601: Missing directory for harvesting files: Could not find a part of the path '<sourceFolder>\files2\ThisDirectoryIsAlsoMissing'.",
5454
@"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.",
5555
}, messages);
56-
});
56+
}, assertSuccess: false);
5757
}
5858

5959
[Fact]
@@ -93,7 +93,7 @@ public void DuplicateFilesSomethingSomething()
9393
8602,
9494
8602,
9595
}, messages);
96-
});
96+
}, assertSuccess: false);
9797
}
9898

9999
[Fact]
@@ -109,7 +109,7 @@ public void HarvestedFilesUnderPackageWithAuthoredFeatureAreOrphaned()
109109
267,
110110
267,
111111
}, messages);
112-
});
112+
}, assertSuccess: false);
113113
}
114114

115115
[Fact]
@@ -300,24 +300,19 @@ public void CanHarvestFilesWithNamedBindPaths()
300300
}
301301

302302
[Fact]
303-
public void CanHarvestFilesWithUnnamedBindPaths()
303+
public void CanHarvestFilesRelativeToSourceFile()
304304
{
305305
var expected = new[]
306306
{
307-
@"flsNNsTNrgmjASmTBbP.45J1F50dEc=PFiles\HarvestedFiles\test1.txt",
308-
@"flsASLR5pHQzLmWRE.Snra7ndH7sIA=PFiles\HarvestedFiles\test2.txt",
309-
@"flsTZFPiMHb.qfUxdGKQYrnXOhZ.8M=PFiles\HarvestedFiles\files1_sub1\test10.txt",
310-
@"flsLGcTTZPIU3ELiWybqnm.PQ0Ih_g=PFiles\HarvestedFiles\files1_sub1\files1_sub2\test120.txt",
311-
@"fls1Jx2Y9Vea_.WZBH_h2e79arvDRU=PFiles\HarvestedFiles\test3.txt",
312-
@"flsJ9gNxWaau2X3ufphQuCV9WwAgcw=PFiles\HarvestedFiles\test4.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",
307+
@"flsiYjLzK34LeZEChPfagEeCq391QE=PFiles\Example Corporation HarvestedFiles\BadAuthoring.wxs",
308+
@"flssFAX35joEC73c.9dGg2Cxy9yZHg=PFiles\Example Corporation HarvestedFiles\BadDirectory.wxs",
309+
@"flsYgiwrDUkZnBEK6iUMkxxaJlD8yQ=PFiles\Example Corporation HarvestedFiles\test1.txt",
310+
@"flsj.cb0sFWqIPHPFSKJSEEaPDuAQ4=PFiles\Example Corporation HarvestedFiles\test2.txt",
311+
@"flsD7JQZm.Ts2375WMT.zsTxqCAf.s=PFiles\Example Corporation HarvestedFiles\files1_sub1\test10.txt",
312+
@"flslrDWblm4pE.4i4jR58_XyYMmR8I=PFiles\Example Corporation HarvestedFiles\files1_sub1\files1_sub2\test120.txt",
318313
};
319314

320-
Build("BindPathsUnnamed.wxs", (msiPath, _) => AssertFileIdsAndTargetPaths(msiPath, expected), addUnnamedBindPaths: true);
315+
Build("RelativeToSource.wxs", (msiPath, _) => AssertFileIdsAndTargetPaths(msiPath, expected), addUnnamedBindPaths: true);
321316
}
322317

323318
[Fact]
@@ -423,12 +418,12 @@ private static void AssertFileIdsAndTargetPaths(string msiPath, string[] expecte
423418
WixAssert.CompareLineByLine(sortedExpected, actual);
424419
}
425420

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)
427422
{
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);
429424
}
430425

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)
432427
{
433428
var sourceFolder = TestData.Get("TestData", "HarvestFiles");
434429

@@ -465,6 +460,11 @@ private static void Build(string file, Action<string, string, string, WixRunnerR
465460

466461
var result = WixRunner.Execute(warningsAsErrors, arguments.ToArray());
467462

463+
if (assertSuccess)
464+
{
465+
result.AssertSuccess();
466+
}
467+
468468
tester(msiPath, sourceFolder, baseFolder, result);
469469
}
470470
}

src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/BindPathsUnnamed.wxs

Lines changed: 0 additions & 19 deletions
This file was deleted.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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>

src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/unnamedbindpath/namedfile.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/unnamedbindpath/unnamedfile.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)