aboutsummaryrefslogtreecommitdiff
path: root/src/tools
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2023-01-15 20:42:08 -0600
committerSean Hall <r.sean.hall@gmail.com>2023-01-15 22:03:31 -0600
commit32024b526d129534b017d4e932f08e6a6f015102 (patch)
tree0de231ef4fdb7bbd3d24bf088288ba1ecf887b4e /src/tools
parentf4329d17538c14569ab7058c1c378aa5b2297b2c (diff)
downloadwix-32024b526d129534b017d4e932f08e6a6f015102.tar.gz
wix-32024b526d129534b017d4e932f08e6a6f015102.tar.bz2
wix-32024b526d129534b017d4e932f08e6a6f015102.zip
Add Name to Payloads created during directory harvesting.
7161
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/heat/DirectoryHarvester.cs9
-rw-r--r--src/tools/test/WixToolsetTest.Heat/DirectoryToPayloadGroupFixture.cs34
-rw-r--r--src/tools/test/WixToolsetTest.Heat/TestData/NestedFiles/Nested/c.txt1
-rw-r--r--src/tools/test/WixToolsetTest.Heat/TestData/NestedFiles/b.txt1
4 files changed, 43 insertions, 2 deletions
diff --git a/src/tools/heat/DirectoryHarvester.cs b/src/tools/heat/DirectoryHarvester.cs
index c153fef5..e69857ab 100644
--- a/src/tools/heat/DirectoryHarvester.cs
+++ b/src/tools/heat/DirectoryHarvester.cs
@@ -177,7 +177,7 @@ namespace WixToolset.Harvesters
177 { 177 {
178 try 178 try
179 { 179 {
180 int fileCount = this.HarvestDirectory(path, "SourceDir\\", harvestParent, generateType); 180 int fileCount = this.HarvestDirectory(path, "", harvestParent, generateType);
181 181
182 if (generateType != GenerateType.PayloadGroup) 182 if (generateType != GenerateType.PayloadGroup)
183 { 183 {
@@ -256,7 +256,7 @@ namespace WixToolset.Harvesters
256 foreach (string filePath in Directory.GetFiles(path)) 256 foreach (string filePath in Directory.GetFiles(path))
257 { 257 {
258 string fileName = Path.GetFileName(filePath); 258 string fileName = Path.GetFileName(filePath);
259 string source = String.Concat(relativePath, fileName); 259 string source = String.Concat("SourceDir\\", relativePath, fileName);
260 260
261 Wix.ISchemaElement newChild; 261 Wix.ISchemaElement newChild;
262 if (generateType == GenerateType.PayloadGroup) 262 if (generateType == GenerateType.PayloadGroup)
@@ -265,6 +265,11 @@ namespace WixToolset.Harvesters
265 newChild = payload; 265 newChild = payload;
266 266
267 payload.SourceFile = source; 267 payload.SourceFile = source;
268
269 if (!String.IsNullOrEmpty(relativePath))
270 {
271 payload.Name = String.Concat(relativePath, fileName);
272 }
268 } 273 }
269 else 274 else
270 { 275 {
diff --git a/src/tools/test/WixToolsetTest.Heat/DirectoryToPayloadGroupFixture.cs b/src/tools/test/WixToolsetTest.Heat/DirectoryToPayloadGroupFixture.cs
index c9b8ee30..9ca84936 100644
--- a/src/tools/test/WixToolsetTest.Heat/DirectoryToPayloadGroupFixture.cs
+++ b/src/tools/test/WixToolsetTest.Heat/DirectoryToPayloadGroupFixture.cs
@@ -76,5 +76,39 @@ namespace WixToolsetTest.Heat
76 }, wxs); 76 }, wxs);
77 } 77 }
78 } 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 }
79 } 113 }
80} 114}
diff --git a/src/tools/test/WixToolsetTest.Heat/TestData/NestedFiles/Nested/c.txt b/src/tools/test/WixToolsetTest.Heat/TestData/NestedFiles/Nested/c.txt
new file mode 100644
index 00000000..17c43215
--- /dev/null
+++ b/src/tools/test/WixToolsetTest.Heat/TestData/NestedFiles/Nested/c.txt
@@ -0,0 +1 @@
This be c.txt. \ No newline at end of file
diff --git a/src/tools/test/WixToolsetTest.Heat/TestData/NestedFiles/b.txt b/src/tools/test/WixToolsetTest.Heat/TestData/NestedFiles/b.txt
new file mode 100644
index 00000000..704b3d88
--- /dev/null
+++ b/src/tools/test/WixToolsetTest.Heat/TestData/NestedFiles/b.txt
@@ -0,0 +1 @@
This is b.txt