diff options
Diffstat (limited to 'src')
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 6927f741..4acd9f24 100644 --- a/src/wix/WixToolset.Core/HarvestFilesCommand.cs +++ b/src/wix/WixToolset.Core/HarvestFilesCommand.cs | |||
| @@ -195,14 +195,16 @@ namespace WixToolset.Core | |||
| 195 | if (-1 != closeParen) | 195 | if (-1 != closeParen) |
| 196 | { | 196 | { |
| 197 | bindName = source.Substring(BindPathOpenString.Length, closeParen - BindPathOpenString.Length); | 197 | bindName = source.Substring(BindPathOpenString.Length, closeParen - BindPathOpenString.Length); |
| 198 | path = source.Substring(BindPathOpenString.Length + bindName.Length + 1); // +1 for the closing brace. | 198 | path = source.Substring(BindPathOpenString.Length + bindName.Length + 1); // +1 for the closing paren. |
| 199 | path = path.TrimStart('\\'); // remove starting '\\' char so the path doesn't look rooted. | 199 | path = path.TrimStart('\\'); // remove starting '\\' char so the path doesn't look rooted. |
| 200 | } | 200 | } |
| 201 | } | 201 | } |
| 202 | 202 | ||
| 203 | if (String.IsNullOrEmpty(bindName)) | 203 | if (String.IsNullOrEmpty(bindName)) |
| 204 | { | 204 | { |
| 205 | resultingDirectories.Add(path); | 205 | var unnamedBindPath = this.Context.BindPaths.SingleOrDefault(bp => bp.Name == null)?.Path; |
| 206 | |||
| 207 | resultingDirectories.Add(unnamedBindPath is null ? path : Path.Combine(unnamedBindPath, path)); | ||
| 206 | } | 208 | } |
| 207 | else | 209 | else |
| 208 | { | 210 | { |
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/HarvestFilesFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/HarvestFilesFixture.cs index e189c42d..2630e295 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/HarvestFilesFixture.cs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/HarvestFilesFixture.cs | |||
| @@ -238,7 +238,7 @@ namespace WixToolsetTest.CoreIntegration | |||
| 238 | } | 238 | } |
| 239 | 239 | ||
| 240 | [Fact] | 240 | [Fact] |
| 241 | public void CanHarvestFilesWithBindPaths() | 241 | public void CanHarvestFilesWithNamedBindPaths() |
| 242 | { | 242 | { |
| 243 | var expected = new[] | 243 | var expected = new[] |
| 244 | { | 244 | { |
| @@ -257,6 +257,27 @@ namespace WixToolsetTest.CoreIntegration | |||
| 257 | } | 257 | } |
| 258 | 258 | ||
| 259 | [Fact] | 259 | [Fact] |
| 260 | public void CanHarvestFilesWithUnnamedBindPaths() | ||
| 261 | { | ||
| 262 | var expected = new[] | ||
| 263 | { | ||
| 264 | @"flsNNsTNrgmjASmTBbP.45J1F50dEc=PFiles\HarvestedFiles\test1.txt", | ||
| 265 | @"flsASLR5pHQzLmWRE.Snra7ndH7sIA=PFiles\HarvestedFiles\test2.txt", | ||
| 266 | @"flsTZFPiMHb.qfUxdGKQYrnXOhZ.8M=PFiles\HarvestedFiles\files1_sub1\test10.txt", | ||
| 267 | @"flsLGcTTZPIU3ELiWybqnm.PQ0Ih_g=PFiles\HarvestedFiles\files1_sub1\files1_sub2\test120.txt", | ||
| 268 | @"fls1Jx2Y9Vea_.WZBH_h2e79arvDRU=PFiles\HarvestedFiles\test3.txt", | ||
| 269 | @"flsJ9gNxWaau2X3ufphQuCV9WwAgcw=PFiles\HarvestedFiles\test4.txt", | ||
| 270 | @"flswcmX9dpMQytmD_5QA5aJ5szoQVA=PFiles\HarvestedFiles\files2_sub2\test20.txt", | ||
| 271 | @"flskKeCKFUtCYMuvw564rgPLJmyBx0=PFiles\HarvestedFiles\files2_sub2\test21.txt", | ||
| 272 | @"fls2agLZFnQwjoijShwT9Z0RwHyGrI=PFiles\HarvestedFiles\files2_sub3\FileName.Extension", | ||
| 273 | @"fls9UMOE.TOv61JuYF8IhvCKb8eous=PFiles\HarvestedFiles\namedfile.txt", | ||
| 274 | @"flsu53T_9CcaBegDflAImGHTajDbJ0=PFiles\HarvestedFiles\unnamedfile.txt", | ||
| 275 | }; | ||
| 276 | |||
| 277 | Build("BindPathsUnnamed.wxs", (msiPath, _) => AssertFileIdsAndTargetPaths(msiPath, expected), addUnnamedBindPath: true); | ||
| 278 | } | ||
| 279 | |||
| 280 | [Fact] | ||
| 260 | public void CanHarvestFilesInStandardDirectory() | 281 | public void CanHarvestFilesInStandardDirectory() |
| 261 | { | 282 | { |
| 262 | var expected = new[] | 283 | var expected = new[] |
| @@ -325,7 +346,7 @@ namespace WixToolsetTest.CoreIntegration | |||
| 325 | Assert.Equal(sortedExpected, actual); | 346 | Assert.Equal(sortedExpected, actual); |
| 326 | } | 347 | } |
| 327 | 348 | ||
| 328 | private static void Build(string file, Action<string, WixRunnerResult> tester, bool isPackage = true, bool warningsAsErrors = true, params string[] additionalCommandLineArguments) | 349 | private static void Build(string file, Action<string, WixRunnerResult> tester, bool isPackage = true, bool warningsAsErrors = true, bool addUnnamedBindPath = false, params string[] additionalCommandLineArguments) |
| 329 | { | 350 | { |
| 330 | var folder = TestData.Get("TestData", "HarvestFiles"); | 351 | var folder = TestData.Get("TestData", "HarvestFiles"); |
| 331 | 352 | ||
| @@ -341,12 +362,17 @@ namespace WixToolsetTest.CoreIntegration | |||
| 341 | "build", | 362 | "build", |
| 342 | Path.Combine(folder, file), | 363 | Path.Combine(folder, file), |
| 343 | "-intermediateFolder", intermediateFolder, | 364 | "-intermediateFolder", intermediateFolder, |
| 344 | "-bindpath", folder, | ||
| 345 | "-bindpath", @$"ToBeHarvested={folder}\files1", | 365 | "-bindpath", @$"ToBeHarvested={folder}\files1", |
| 346 | "-bindpath", @$"ToBeHarvested={folder}\files2", | 366 | "-bindpath", @$"ToBeHarvested={folder}\files2", |
| 347 | "-o", msiPath, | 367 | "-o", msiPath, |
| 348 | }; | 368 | }; |
| 349 | 369 | ||
| 370 | if (addUnnamedBindPath) | ||
| 371 | { | ||
| 372 | arguments.Add("-bindpath"); | ||
| 373 | arguments.Add(Path.Combine(folder, "unnamedbindpath")); | ||
| 374 | } | ||
| 375 | |||
| 350 | if (additionalCommandLineArguments.Length > 0) | 376 | if (additionalCommandLineArguments.Length > 0) |
| 351 | { | 377 | { |
| 352 | arguments.AddRange(additionalCommandLineArguments); | 378 | 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. | |||
