aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/wix/WixToolset.Core/HarvestFilesCommand.cs51
-rw-r--r--src/wix/test/WixToolsetTest.CoreIntegration/HarvestFilesFixture.cs24
-rw-r--r--src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/SomeExclusionsMissing.wxs17
3 files changed, 66 insertions, 26 deletions
diff --git a/src/wix/WixToolset.Core/HarvestFilesCommand.cs b/src/wix/WixToolset.Core/HarvestFilesCommand.cs
index ed78e808..25698ece 100644
--- a/src/wix/WixToolset.Core/HarvestFilesCommand.cs
+++ b/src/wix/WixToolset.Core/HarvestFilesCommand.cs
@@ -135,33 +135,32 @@ namespace WixToolset.Core
135 135
136 var files = new List<WildcardFile>(); 136 var files = new List<WildcardFile>();
137 137
138 try 138 foreach (var pattern in patterns)
139 { 139 {
140 foreach (var pattern in patterns) 140 // Resolve bind paths, if any, which might result in multiple directories.
141 foreach (var path in this.ResolveBindPaths(sourceLineNumbers, pattern))
141 { 142 {
142 // Resolve bind paths, if any, which might result in multiple directories. 143 var sourceDirectory = String.IsNullOrEmpty(sourcePath) ? Path.GetDirectoryName(sourceLineNumbers.FileName) : sourcePath;
143 foreach (var path in this.ResolveBindPaths(sourceLineNumbers, pattern)) 144 var recursive = path.IndexOf("**") >= 0;
144 { 145 var filePortion = Path.GetFileName(path);
145 var sourceDirectory = String.IsNullOrEmpty(sourcePath) ? Path.GetDirectoryName(sourceLineNumbers.FileName) : sourcePath; 146 var directoryPortion = Path.GetDirectoryName(path).TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
146 var recursive = path.IndexOf("**") >= 0;
147 var filePortion = Path.GetFileName(path);
148 var directoryPortion = Path.GetDirectoryName(path).TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
149 147
150 if (directoryPortion?.EndsWith(@"\**") == true) 148 if (directoryPortion?.EndsWith(@"\**") == true)
151 { 149 {
152 directoryPortion = directoryPortion.Substring(0, directoryPortion.Length - 3); 150 directoryPortion = directoryPortion.Substring(0, directoryPortion.Length - 3);
153 } 151 }
154
155 if (directoryPortion is null || directoryPortion.Length == 0 || directoryPortion == "**")
156 {
157 directoryPortion = sourceDirectory;
158 152
159 } 153 if (directoryPortion is null || directoryPortion.Length == 0 || directoryPortion == "**")
160 else if (!Path.IsPathRooted(directoryPortion)) 154 {
161 { 155 directoryPortion = sourceDirectory;
162 directoryPortion = Path.Combine(sourceDirectory, directoryPortion); 156 }
163 } 157 else if (!Path.IsPathRooted(directoryPortion))
158 {
159 directoryPortion = Path.Combine(sourceDirectory, directoryPortion);
160 }
164 161
162 try
163 {
165 var recursiveDirOffset = directoryPortion.Length + 1; 164 var recursiveDirOffset = directoryPortion.Length + 1;
166 165
167 var foundFiles = Directory.EnumerateFiles(directoryPortion, filePortion, recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly); 166 var foundFiles = Directory.EnumerateFiles(directoryPortion, filePortion, recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly);
@@ -176,12 +175,12 @@ namespace WixToolset.Core
176 }); 175 });
177 } 176 }
178 } 177 }
178 catch (DirectoryNotFoundException e)
179 {
180 this.Messaging.Write(OptimizerWarnings.ExpectedDirectory(harvestFile.SourceLineNumbers, e.Message));
181 }
179 } 182 }
180 } 183 }
181 catch (DirectoryNotFoundException e)
182 {
183 this.Messaging.Write(OptimizerWarnings.ExpectedDirectory(harvestFile.SourceLineNumbers, e.Message));
184 }
185 184
186 return files; 185 return files;
187 } 186 }
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/HarvestFilesFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/HarvestFilesFixture.cs
index 949746ac..a680d145 100644
--- a/src/wix/test/WixToolsetTest.CoreIntegration/HarvestFilesFixture.cs
+++ b/src/wix/test/WixToolsetTest.CoreIntegration/HarvestFilesFixture.cs
@@ -57,6 +57,30 @@ namespace WixToolsetTest.CoreIntegration
57 } 57 }
58 58
59 [Fact] 59 [Fact]
60 public void MissingHarvestExclusionsDoesNotBlockAllHarvesting()
61 {
62 Build("SomeExclusionsMissing.wxs", (msiPath, sourceFolder, baseFolder, result) =>
63 {
64 var expectedWarnings = new[]
65 {
66 @"8601: Missing directory for harvesting files: Could not find a part of the path '<sourceFolder>\files2\files2_sub2\MissingDirectory'.",
67 @"8601: Missing directory for harvesting files: Could not find a part of the path '<sourceFolder>\files2\files2_sub2\ThisDirectoryIsAlsoMissing'.",
68 };
69
70 var expectedFiles = new[]
71 {
72 @"flsCswDB8sBfZz7_oHNtra3tiFivPE=PFiles\MsiPackage\test20.txt",
73 @"fls4200C_IADZMINQyhQg52G3WxxfU=PFiles\MsiPackage\test21.txt",
74 };
75
76 var messages = result.Messages.Select(m => FormatMessage(m, sourceFolder, baseFolder)).ToArray();
77 WixAssert.CompareLineByLine(expectedWarnings, messages);
78
79 AssertFileIdsAndTargetPaths(msiPath, expectedFiles);
80 }, warningsAsErrors: false);
81 }
82
83 [Fact]
60 public void DuplicateFilesSomethingSomething() 84 public void DuplicateFilesSomethingSomething()
61 { 85 {
62 Build("DuplicateFiles.wxs", (_, result) => 86 Build("DuplicateFiles.wxs", (_, result) =>
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/SomeExclusionsMissing.wxs b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/SomeExclusionsMissing.wxs
new file mode 100644
index 00000000..104518bd
--- /dev/null
+++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/HarvestFiles/SomeExclusionsMissing.wxs
@@ -0,0 +1,17 @@
1<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
2 <Package Id="WixToolsetTest.SomeExclusionsMissing" Name="MsiPackage" Version="1.0.0.0" Manufacturer="Example Corporation">
3
4 <Files Include="files2\files2_sub2\**">
5 <Exclude Files="files2\files2_sub2\MissingDirectory\**" />
6 <Exclude Files="files2\files2_sub2\pleasedontincludeme.dat" />
7 <Exclude Files="files2\files2_sub2\ThisDirectoryIsAlsoMissing\**" />
8 </Files>
9
10 </Package>
11
12 <Fragment>
13 <StandardDirectory Id="ProgramFilesFolder">
14 <Directory Id="INSTALLFOLDER" Name="MsiPackage" />
15 </StandardDirectory>
16 </Fragment>
17</Wix>