@joebigelow / wix / commits / 1ade630c

Add verbose messages around harvesting.

Bob Arnson committed Aug 18, 2024 at 19:05 UTC 1ade630c42bed442f4904c26b6a897a2daaa193e
3 files changed +63 -3
src/wix/WixToolset.Core/HarvestFilesCommand.cs
+7
@@ -57,6 +57,11 @@ namespace WixToolset.Core
57 var included = this.GetWildcardFiles(harvestFile, inclusions);
58 var excluded = this.GetWildcardFiles(harvestFile, exclusions);
59
60 + foreach (var excludedFile in excluded)
61 + {
62 + this.Messaging.Write(OptimizerVerboses.ExcludedFile(harvestFile.SourceLineNumbers, excludedFile.Path));
63 + }
64 +
65 resolvedFiles = included.Except(excluded, comparer).ToList();
66
67 if (!resolvedFiles.Any())
@@ -90,6 +95,8 @@ namespace WixToolset.Core
95
96 var id = this.ParseHelper.CreateIdentifier("fls", directoryId, name);
97
98 + this.Messaging.Write(OptimizerVerboses.HarvestedFile(harvestFile.SourceLineNumbers, file));
99 +
100 section.AddSymbol(new FileSymbol(harvestFile.SourceLineNumbers, id)
101 {
102 ComponentRef = id.Id,
src/wix/WixToolset.Core/OptimizerVerboses.cs new
+30
@@ -0,0 +1,30 @@
1 +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2 +
3 +namespace WixToolset.Core
4 +{
5 + using WixToolset.Data;
6 +
7 + internal static class OptimizerVerboses
8 + {
9 + public static Message HarvestedFile(SourceLineNumber sourceLineNumbers, string harvestedFile)
10 + {
11 + return Message(sourceLineNumbers, Ids.HarvestedFile, "Harvested file: {0}", harvestedFile);
12 + }
13 +
14 + public static Message ExcludedFile(SourceLineNumber sourceLineNumbers, string excludedFile)
15 + {
16 + return Message(sourceLineNumbers, Ids.ExcludedFile, "File excluded from harvesting: {0}", excludedFile);
17 + }
18 +
19 + private static Message Message(SourceLineNumber sourceLineNumber, Ids id, string format, params object[] args)
20 + {
21 + return new Message(sourceLineNumber, MessageLevel.Verbose, (int)id, format, args);
22 + }
23 +
24 + public enum Ids
25 + {
26 + HarvestedFile = 8700,
27 + ExcludedFile = 8701,
28 + }
29 + }
30 +}
src/wix/test/WixToolsetTest.CoreIntegration/HarvestFilesFixture.cs
+26 -3
@@ -3,6 +3,7 @@
3 namespace WixToolsetTest.CoreIntegration
4 {
5 using System;
6 + using System.Collections.Generic;
7 using System.Data;
8 using System.IO;
9 using System.Linq;
@@ -291,6 +292,23 @@ namespace WixToolsetTest.CoreIntegration
292 Build("PackageFiveLiner.wxs", (msiPath, _) => AssertFileIdsAndTargetPaths(msiPath, expected));
293 }
294
295 + [Fact]
296 + public void CanGetVerboseHarvestingDetails()
297 + {
298 + Build("Feature.wxs", (_, result) =>
299 + {
300 + var messages = result.Messages.Select(m => m.Id).Where(i => i >= 8700 && i < 8800);
301 + Assert.Equal(new[]
302 + {
303 + 8701,
304 + 8700,
305 + 8701,
306 + 8700,
307 + 8700,
308 + }, messages);
309 + }, additionalCommandLineArguments: "-v");
310 + }
311 +
312 private static void AssertFileIdsAndTargetPaths(string msiPath, string[] expected)
313 {
314 var pkg = new WixToolset.Dtf.WindowsInstaller.Package.InstallPackage(msiPath,
@@ -301,7 +319,7 @@ namespace WixToolsetTest.CoreIntegration
319 Assert.Equal(sortedExpected, actual);
320 }
321
304 - private static void Build(string file, Action<string, WixRunnerResult> tester, bool isPackage = true)
322 + private static void Build(string file, Action<string, WixRunnerResult> tester, bool isPackage = true, params string[] additionalCommandLineArguments)
323 {
324 var folder = TestData.Get("TestData", "HarvestFiles");
325
@@ -312,7 +330,7 @@ namespace WixToolsetTest.CoreIntegration
330 var binFolder = Path.Combine(baseFolder, "bin");
331 var msiPath = Path.Combine(binFolder, isPackage ? "test.msi" : "test.msm");
332
315 - var arguments = new[]
333 + var arguments = new List<string>()
334 {
335 "build",
336 Path.Combine(folder, file),
@@ -323,7 +341,12 @@ namespace WixToolsetTest.CoreIntegration
341 "-o", msiPath,
342 };
343
326 - var result = WixRunner.Execute(arguments);
344 + if (additionalCommandLineArguments.Length > 0)
345 + {
346 + arguments.AddRange(additionalCommandLineArguments);
347 + }
348 +
349 + var result = WixRunner.Execute(arguments.ToArray());
350
351 tester(msiPath, result);
352 }