diff options
| author | Bob Arnson <bob@firegiant.com> | 2024-09-02 22:14:19 -0400 |
|---|---|---|
| committer | Bob Arnson <bob@firegiant.com> | 2024-09-02 22:14:19 -0400 |
| commit | 05d7fe5f197394fcc883b3cc0f3a294172feadcc (patch) | |
| tree | 3efe1203c6fc5eb8757118748bec6893b7773657 | |
| parent | 1011c5609bc12ded5188dc76484fc5075d24617c (diff) | |
| download | wix-bob/wixbug_8585.tar.gz wix-bob/wixbug_8585.tar.bz2 wix-bob/wixbug_8585.zip | |
Use an unnamed bindpath as a default root for...bob/wixbug_8585
...harvesting files (as documented).
- Fixes https://github.com/wixtoolset/issues/issues/8585
6 files changed, 55 insertions, 6 deletions
diff --git a/src/wix/WixToolset.Core/ExtensibilityServices/FileResolver.cs b/src/wix/WixToolset.Core/ExtensibilityServices/FileResolver.cs index 8f08e75e..c4f212c9 100644 --- a/src/wix/WixToolset.Core/ExtensibilityServices/FileResolver.cs +++ b/src/wix/WixToolset.Core/ExtensibilityServices/FileResolver.cs | |||
| @@ -90,7 +90,7 @@ namespace WixToolset.Core.ExtensibilityServices | |||
| 90 | if (-1 != closeParen) | 90 | if (-1 != closeParen) |
| 91 | { | 91 | { |
| 92 | bindName = source.Substring(BindPathOpenString.Length, closeParen - BindPathOpenString.Length); | 92 | bindName = source.Substring(BindPathOpenString.Length, closeParen - BindPathOpenString.Length); |
| 93 | path = source.Substring(BindPathOpenString.Length + bindName.Length + 1); // +1 for the closing brace. | 93 | path = source.Substring(BindPathOpenString.Length + bindName.Length + 1); // +1 for the closing paren. |
| 94 | path = path.TrimStart('\\'); // remove starting '\\' char so the path doesn't look rooted. | 94 | path = path.TrimStart('\\'); // remove starting '\\' char so the path doesn't look rooted. |
| 95 | } | 95 | } |
| 96 | } | 96 | } |
diff --git a/src/wix/WixToolset.Core/HarvestFilesCommand.cs b/src/wix/WixToolset.Core/HarvestFilesCommand.cs index a8c716d0..6209c6b3 100644 --- a/src/wix/WixToolset.Core/HarvestFilesCommand.cs +++ b/src/wix/WixToolset.Core/HarvestFilesCommand.cs | |||
| @@ -199,14 +199,16 @@ namespace WixToolset.Core | |||
| 199 | if (-1 != closeParen) | 199 | if (-1 != closeParen) |
| 200 | { | 200 | { |
| 201 | bindName = source.Substring(BindPathOpenString.Length, closeParen - BindPathOpenString.Length); | 201 | bindName = source.Substring(BindPathOpenString.Length, closeParen - BindPathOpenString.Length); |
| 202 | path = source.Substring(BindPathOpenString.Length + bindName.Length + 1); // +1 for the closing brace. | 202 | path = source.Substring(BindPathOpenString.Length + bindName.Length + 1); // +1 for the closing paren. |
| 203 | path = path.TrimStart('\\'); // remove starting '\\' char so the path doesn't look rooted. | 203 | path = path.TrimStart('\\'); // remove starting '\\' char so the path doesn't look rooted. |
| 204 | } | 204 | } |
| 205 | } | 205 | } |
| 206 | 206 | ||
| 207 | if (String.IsNullOrEmpty(bindName)) | 207 | if (String.IsNullOrEmpty(bindName)) |
| 208 | { | 208 | { |
| 209 | resultingDirectories.Add(path); | 209 | var unnamedBindPath = this.Context.BindPaths.SingleOrDefault(bp => bp.Name == null)?.Path; |
| 210 | |||
| 211 | resultingDirectories.Add(unnamedBindPath is null ? path : Path.Combine(unnamedBindPath, path)); | ||
| 210 | } | 212 | } |
| 211 | else | 213 | else |
| 212 | { | 214 | { |
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/HarvestFilesFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/HarvestFilesFixture.cs index 7da47f6b..e8d545c8 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/HarvestFilesFixture.cs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/HarvestFilesFixture.cs | |||
| @@ -236,7 +236,7 @@ namespace WixToolsetTest.CoreIntegration | |||
| 236 | } | 236 | } |
| 237 | 237 | ||
| 238 | [Fact] | 238 | [Fact] |
| 239 | public void CanHarvestFilesWithBindPaths() | 239 | public void CanHarvestFilesWithNamedBindPaths() |
| 240 | { | 240 | { |
| 241 | var expected = new[] | 241 | var expected = new[] |
| 242 | { | 242 | { |
| @@ -255,6 +255,27 @@ namespace WixToolsetTest.CoreIntegration | |||
| 255 | } | 255 | } |
| 256 | 256 | ||
| 257 | [Fact] | 257 | [Fact] |
| 258 | public void CanHarvestFilesWithUnnamedBindPaths() | ||
| 259 | { | ||
| 260 | var expected = new[] | ||
| 261 | { | ||
| 262 | @"flsNNsTNrgmjASmTBbP.45J1F50dEc=PFiles\HarvestedFiles\test1.txt", | ||
| 263 | @"flsASLR5pHQzLmWRE.Snra7ndH7sIA=PFiles\HarvestedFiles\test2.txt", | ||
| 264 | @"flsTZFPiMHb.qfUxdGKQYrnXOhZ.8M=PFiles\HarvestedFiles\files1_sub1\test10.txt", | ||
| 265 | @"flsLGcTTZPIU3ELiWybqnm.PQ0Ih_g=PFiles\HarvestedFiles\files1_sub1\files1_sub2\test120.txt", | ||
| 266 | @"fls1Jx2Y9Vea_.WZBH_h2e79arvDRU=PFiles\HarvestedFiles\test3.txt", | ||
| 267 | @"flsJ9gNxWaau2X3ufphQuCV9WwAgcw=PFiles\HarvestedFiles\test4.txt", | ||
| 268 | @"flswcmX9dpMQytmD_5QA5aJ5szoQVA=PFiles\HarvestedFiles\files2_sub2\test20.txt", | ||
| 269 | @"flskKeCKFUtCYMuvw564rgPLJmyBx0=PFiles\HarvestedFiles\files2_sub2\test21.txt", | ||
| 270 | @"fls2agLZFnQwjoijShwT9Z0RwHyGrI=PFiles\HarvestedFiles\files2_sub3\FileName.Extension", | ||
| 271 | @"fls9UMOE.TOv61JuYF8IhvCKb8eous=PFiles\HarvestedFiles\namedfile.txt", | ||
| 272 | @"flsu53T_9CcaBegDflAImGHTajDbJ0=PFiles\HarvestedFiles\unnamedfile.txt", | ||
| 273 | }; | ||
| 274 | |||
| 275 | Build("BindPathsUnnamed.wxs", (msiPath, _) => AssertFileIdsAndTargetPaths(msiPath, expected), addUnnamedBindPath: true); | ||
| 276 | } | ||
| 277 | |||
| 278 | [Fact] | ||
| 258 | public void CanHarvestFilesInStandardDirectory() | 279 | public void CanHarvestFilesInStandardDirectory() |
| 259 | { | 280 | { |
| 260 | var expected = new[] | 281 | var expected = new[] |
| @@ -319,7 +340,7 @@ namespace WixToolsetTest.CoreIntegration | |||
| 319 | Assert.Equal(sortedExpected, actual); | 340 | Assert.Equal(sortedExpected, actual); |
| 320 | } | 341 | } |
| 321 | 342 | ||
| 322 | private static void Build(string file, Action<string, WixRunnerResult> tester, bool isPackage = true, params string[] additionalCommandLineArguments) | 343 | private static void Build(string file, Action<string, WixRunnerResult> tester, bool isPackage = true, bool addUnnamedBindPath = false, params string[] additionalCommandLineArguments) |
| 323 | { | 344 | { |
| 324 | var folder = TestData.Get("TestData", "HarvestFiles"); | 345 | var folder = TestData.Get("TestData", "HarvestFiles"); |
| 325 | 346 | ||
| @@ -335,12 +356,17 @@ namespace WixToolsetTest.CoreIntegration | |||
| 335 | "build", | 356 | "build", |
| 336 | Path.Combine(folder, file), | 357 | Path.Combine(folder, file), |
| 337 | "-intermediateFolder", intermediateFolder, | 358 | "-intermediateFolder", intermediateFolder, |
| 338 | "-bindpath", folder, | ||
| 339 | "-bindpath", @$"ToBeHarvested={folder}\files1", | 359 | "-bindpath", @$"ToBeHarvested={folder}\files1", |
| 340 | "-bindpath", @$"ToBeHarvested={folder}\files2", | 360 | "-bindpath", @$"ToBeHarvested={folder}\files2", |
| 341 | "-o", msiPath, | 361 | "-o", msiPath, |
| 342 | }; | 362 | }; |
| 343 | 363 | ||
| 364 | if (addUnnamedBindPath) | ||
| 365 | { | ||
| 366 | arguments.Add("-bindpath"); | ||
| 367 | arguments.Add(Path.Combine(folder, "unnamedbindpath")); | ||
| 368 | } | ||
| 369 | |||
| 344 | if (additionalCommandLineArguments.Length > 0) | 370 | if (additionalCommandLineArguments.Length > 0) |
| 345 | { | 371 | { |
| 346 | arguments.AddRange(additionalCommandLineArguments); | 372 | 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 00000000..cd764926 --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/BindPathsUnnamed.wxs | |||
| @@ -0,0 +1,19 @@ | |||
| 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/unnamedbindpath/namedfile.txt b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/unnamedbindpath/namedfile.txt new file mode 100644 index 00000000..d32727e0 --- /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 00000000..d32727e0 --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/unnamedbindpath/unnamedfile.txt | |||
| @@ -0,0 +1 @@ | |||
| This is test.txt. | |||
