Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure naked files take Subdirectory into account. #557

Merged
merged 2 commits into from
Dec 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
163 changes: 97 additions & 66 deletions src/wix/WixToolset.Core/Compiler.cs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/wix/WixToolset.Core/Linker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ private void FlattenGroup(string parentTypeAndId, Stack<string> loopDetector, Di
var childTypeAndId = this.CombineTypeAndId(wixComplexReferenceRow.ChildType, wixComplexReferenceRow.Child);
if (loopDetector.Contains(childTypeAndId))
{
// Create a comma delimited list of the references that participate in the
// Create an arrow-delimited list of the references that participate in the
// loop for the error message. Start at the bottom of the stack and work the
// way up to present the loop as a directed graph.
var loop = String.Join(" -> ", loopDetector);
Expand Down
35 changes: 35 additions & 0 deletions src/wix/test/WixToolsetTest.CoreIntegration/HarvestFilesFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,41 @@ public void CanGetVerboseHarvestingDetails()
}, additionalCommandLineArguments: "-v");
}

[Fact]
public void CanHarvestFilesWithDuplicateNames()
{
var expectedFiles = new[]
{
"File:fls47G631z.20kTPzBwIPjGuWifsVo\tfls47G631z.20kTPzBwIPjGuWifsVo\tfile.x\t0\t\t\t512\t2",
"File:flshOXYGoD0VHcQhrkIILRPNOVbYuM\tflshOXYGoD0VHcQhrkIILRPNOVbYuM\tfile.x\t0\t\t\t512\t1",
"File:flsp2QdFvBeSwll1i5tN0jM72w3Hu4\tflsp2QdFvBeSwll1i5tN0jM72w3Hu4\tfile.x\t0\t\t\t512\t3",
"File:flsqopW5ihQpwCTF7t_51GkHd4Hf6s\tflsqopW5ihQpwCTF7t_51GkHd4Hf6s\tfile.x\t0\t\t\t512\t4",
};

var expectedFilesAndDirectories = new[]
{
@"fls47G631z.20kTPzBwIPjGuWifsVo=PFiles\Example Corporation MsiPackage\b\file.x",
@"flshOXYGoD0VHcQhrkIILRPNOVbYuM=PFiles\Example Corporation MsiPackage\a\file.x",
@"flsp2QdFvBeSwll1i5tN0jM72w3Hu4=PFiles\Example Corporation MsiPackage\c\file.x",
@"flsqopW5ihQpwCTF7t_51GkHd4Hf6s=PFiles\Example Corporation MsiPackage\d\file.x",
};

Build("DuplicateNames.wxs", (msiPath, result) => AssertFileAndComponentIdsAndTargetPaths(msiPath, result, expectedFiles, expectedFilesAndDirectories));
}

private static void AssertFileAndComponentIdsAndTargetPaths(string msiPath, WixRunnerResult result, string[] expectedFiles, string[] expectedFilesAndDirectories)
{
result.AssertSuccess();

var files = Query.QueryDatabase(msiPath, new[] { "File" })
.OrderBy(s => s)
.ToArray();

Assert.Equal(expectedFiles, files);

AssertFileIdsAndTargetPaths(msiPath, expectedFilesAndDirectories);
}

private static void AssertFileIdsAndTargetPaths(string msiPath, string[] expected)
{
var pkg = new WixToolset.Dtf.WindowsInstaller.Package.InstallPackage(msiPath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,13 @@ public void CanBuildNakedFilesUnderPackage()
AssertFileComponentIds(4, rows);
}

[Fact]
public void CanBuildNakedFilesUnderPackageWithDuplicateNames()
{
var rows = BuildAndQueryComponentAndFileTables("DuplicateNames.wxs");
AssertFileComponentIds(5, rows);
}

[Fact]
public void CanBuildNakedFilesUnderPackageWithDefaultInstallFolder()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
<Package Name="MsiPackage" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="047730a5-30fe-4a62-a520-da9381b8226a">
<Files Include="dupes\**" />
</Package>
</Wix>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
<Package Name="GenManyComponents 5x1" Manufacturer="FireGiant" Version="1.0.0.0" UpgradeCode="b146c9a9-7184-413c-8ab2-b65ed869feb9">
<File Subdirectory='0000' Name='0000.x' Source='$(sys.SOURCEFILEPATH)' />
<File Subdirectory='0001' Name='0000.x' Source='$(sys.SOURCEFILEPATH)' />
<File Subdirectory='0002' Name='0000.x' Source='$(sys.SOURCEFILEPATH)' />
<File Subdirectory='0003' Name='0000.x' Source='$(sys.SOURCEFILEPATH)' />
<File Subdirectory='0004' Name='0000.x' Source='$(sys.SOURCEFILEPATH)' />
</Package>
</Wix>
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
<Package Name="MsiPackage" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="047730a5-30fe-4a62-a520-da9381b8226a">
<MajorUpgrade DowngradeErrorMessage="Downgrade error message." />

<File Directory="INSTALLFOLDER" Source="test.txt" />
<File Directory="INSTALLFOLDER" Source="test.txt" Name="test2.txt" />
<File Directory="INSTALLFOLDER" Source="test.txt" Name="test3.txt" />
<File Directory="INSTALLFOLDER" Source="test.txt" Name="test4.txt" />
<File Directory="INSTALLFOLDER" Subdirectory="X" Source="test.txt" />
<File Directory="INSTALLFOLDER" Subdirectory="X" Source="test.txt" Name="test2.txt" />
<File Directory="INSTALLFOLDER" Subdirectory="X3" Source="test.txt" Name="test3.txt" />
<File Directory="INSTALLFOLDER" Subdirectory="X4" Source="test.txt" Name="test4.txt" />
</Package>
</Wix>
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
<Package Name="MsiPackage" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="047730a5-30fe-4a62-a520-da9381b8226a">
<MajorUpgrade DowngradeErrorMessage="Downgrade error message." />

<File Source="test.txt" />
<File Source="test.txt" Name="test2.txt" />
<File Source="test.txt" Name="test3.txt" />
<File Source="test.txt" Name="test4.txt" />
<File Subdirectory="X" Name="test.txt" Source="test.txt" />
<File Subdirectory="X" Name="test2.txt" Source="test.txt" />
<File Subdirectory="X3" Name="test3.txt" Source="test.txt" />
<File Subdirectory="X4" Name="test4.txt" Source="test.txt" />
</Package>
</Wix>
Loading