@joebigelow / wix / commits / 32024b52

Add Name to Payloads created during directory harvesting.

7161

Sean Hall committed Jan 15, 2023 at 20:42 UTC 32024b526d129534b017d4e932f08e6a6f015102
4 files changed +43 -2
src/tools/heat/DirectoryHarvester.cs
+7 -2
@@ -177,7 +177,7 @@ namespace WixToolset.Harvesters
177 {
178 try
179 {
180 - int fileCount = this.HarvestDirectory(path, "SourceDir\\", harvestParent, generateType);
180 + int fileCount = this.HarvestDirectory(path, "", harvestParent, generateType);
181
182 if (generateType != GenerateType.PayloadGroup)
183 {
@@ -256,7 +256,7 @@ namespace WixToolset.Harvesters
256 foreach (string filePath in Directory.GetFiles(path))
257 {
258 string fileName = Path.GetFileName(filePath);
259 - string source = String.Concat(relativePath, fileName);
259 + string source = String.Concat("SourceDir\\", relativePath, fileName);
260
261 Wix.ISchemaElement newChild;
262 if (generateType == GenerateType.PayloadGroup)
@@ -265,6 +265,11 @@ namespace WixToolset.Harvesters
265 newChild = payload;
266
267 payload.SourceFile = source;
268 +
269 + if (!String.IsNullOrEmpty(relativePath))
270 + {
271 + payload.Name = String.Concat(relativePath, fileName);
272 + }
273 }
274 else
275 {
src/tools/test/WixToolsetTest.Heat/DirectoryToPayloadGroupFixture.cs
+34
@@ -76,5 +76,39 @@ namespace WixToolsetTest.Heat
76 }, wxs);
77 }
78 }
79 +
80 + [Fact]
81 + public void CanHarvestNestedFiles()
82 + {
83 + var folder = TestData.Get("TestData", "NestedFiles");
84 +
85 + using (var fs = new DisposableFileSystem())
86 + {
87 + var outputPath = Path.Combine(fs.GetFolder(), "out.wxs");
88 +
89 + var args = new[]
90 + {
91 + "dir", folder,
92 + "-generate", "payloadgroup",
93 + "-o", outputPath
94 + };
95 +
96 + var result = HeatRunner.Execute(args);
97 + result.AssertSuccess();
98 +
99 + var wxs = File.ReadAllLines(outputPath).Select(s => s.Replace("\"", "'")).ToArray();
100 + WixAssert.CompareLineByLine(new[]
101 + {
102 + "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>",
103 + " <Fragment>",
104 + " <PayloadGroup Id='TARGETDIR'>",
105 + " <Payload SourceFile='SourceDir\\Nested\\c.txt' Name='Nested\\c.txt' />",
106 + " <Payload SourceFile='SourceDir\\b.txt' />",
107 + " </PayloadGroup>",
108 + " </Fragment>",
109 + "</Wix>",
110 + }, wxs);
111 + }
112 + }
113 }
114 }
src/tools/test/WixToolsetTest.Heat/TestData/NestedFiles/Nested/c.txt new
+1
@@ -0,0 +1 @@
1 +This be c.txt.
\ No newline at end of file
src/tools/test/WixToolsetTest.Heat/TestData/NestedFiles/b.txt new
+1
@@ -0,0 +1 @@
1 +This is b.txt