diff options
author | Rob Mensching <rob@firegiant.com> | 2022-07-26 17:20:39 -0700 |
---|---|---|
committer | Rob Mensching <rob@firegiant.com> | 2022-08-01 20:25:19 -0700 |
commit | a627ca9b720047e633a8fe72003ab9bee31006c5 (patch) | |
tree | 2bc8a924bb4141ab718e74d08f6459a0ffe8d573 /src/tools/test/WixToolsetTest.Heat | |
parent | 521eb3c9cf38823a2c4019abb85dc0b3200b92cb (diff) | |
download | wix-a627ca9b720047e633a8fe72003ab9bee31006c5.tar.gz wix-a627ca9b720047e633a8fe72003ab9bee31006c5.tar.bz2 wix-a627ca9b720047e633a8fe72003ab9bee31006c5.zip |
Create WixToolset.Heat.nupkg to distribute heat.exe and Heat targets
Moves Heat functionality to the "tools" layer and packages it all
up in WixToolset.Heat.nupkg for distribution in WiX v4.
Completes 6838
Diffstat (limited to 'src/tools/test/WixToolsetTest.Heat')
-rw-r--r-- | src/tools/test/WixToolsetTest.Heat/HeatRunner.cs | 92 | ||||
-rw-r--r-- | src/tools/test/WixToolsetTest.Heat/WixToolsetTest.Heat.csproj | 20 |
2 files changed, 112 insertions, 0 deletions
diff --git a/src/tools/test/WixToolsetTest.Heat/HeatRunner.cs b/src/tools/test/WixToolsetTest.Heat/HeatRunner.cs new file mode 100644 index 00000000..287698a9 --- /dev/null +++ b/src/tools/test/WixToolsetTest.Heat/HeatRunner.cs | |||
@@ -0,0 +1,92 @@ | |||
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 WixToolsetTest.Harvesters | ||
4 | { | ||
5 | using System; | ||
6 | using System.Collections.Generic; | ||
7 | using System.Threading; | ||
8 | using System.Threading.Tasks; | ||
9 | using WixToolset.Core; | ||
10 | using WixToolset.Core.Burn; | ||
11 | using WixToolset.Core.TestPackage; | ||
12 | using WixToolset.Data; | ||
13 | using WixToolset.Extensibility.Data; | ||
14 | using WixToolset.Extensibility.Services; | ||
15 | using WixToolset.Harvesters; | ||
16 | |||
17 | /// <summary> | ||
18 | /// Utility class to emulate heat.exe. | ||
19 | /// </summary> | ||
20 | public static class HeatRunner | ||
21 | { | ||
22 | /// <summary> | ||
23 | /// Emulates calling heat.exe. | ||
24 | /// </summary> | ||
25 | /// <param name="args"></param> | ||
26 | /// <param name="messages"></param> | ||
27 | /// <param name="warningsAsErrors"></param> | ||
28 | /// <returns></returns> | ||
29 | public static int Execute(string[] args, out List<Message> messages, bool warningsAsErrors = true) | ||
30 | { | ||
31 | var serviceProvider = WixToolsetServiceProviderFactory.CreateServiceProvider(); | ||
32 | var task = Execute(args, serviceProvider, out messages, warningsAsErrors: warningsAsErrors); | ||
33 | return task.Result; | ||
34 | } | ||
35 | |||
36 | /// <summary> | ||
37 | /// Emulates calling wix.exe with standard backends. | ||
38 | /// This overload always treats warnings as errors. | ||
39 | /// </summary> | ||
40 | /// <param name="args"></param> | ||
41 | /// <returns></returns> | ||
42 | public static WixRunnerResult Execute(params string[] args) | ||
43 | { | ||
44 | return Execute(true, args); | ||
45 | } | ||
46 | |||
47 | /// <summary> | ||
48 | /// Emulates calling wix.exe with standard backends. | ||
49 | /// </summary> | ||
50 | /// <param name="warningsAsErrors"></param> | ||
51 | /// <param name="args"></param> | ||
52 | /// <returns></returns> | ||
53 | public static WixRunnerResult Execute(bool warningsAsErrors, params string[] args) | ||
54 | { | ||
55 | var serviceProvider = WixToolsetServiceProviderFactory.CreateServiceProvider(); | ||
56 | var exitCode = Execute(args, serviceProvider, out var messages, warningsAsErrors: warningsAsErrors); | ||
57 | return new WixRunnerResult { ExitCode = exitCode.Result, Messages = messages.ToArray() }; | ||
58 | } | ||
59 | |||
60 | /// <summary> | ||
61 | /// Emulates calling wix.exe with standard backends. | ||
62 | /// </summary> | ||
63 | /// <param name="args"></param> | ||
64 | /// <param name="coreProvider"></param> | ||
65 | /// <param name="messages"></param> | ||
66 | /// <param name="warningsAsErrors"></param> | ||
67 | /// <returns></returns> | ||
68 | public static Task<int> Execute(string[] args, IWixToolsetCoreServiceProvider coreProvider, out List<Message> messages, bool warningsAsErrors = true) | ||
69 | { | ||
70 | coreProvider.AddBundleBackend(); | ||
71 | |||
72 | var listener = new TestMessageListener(); | ||
73 | |||
74 | messages = listener.Messages; | ||
75 | |||
76 | var messaging = coreProvider.GetService<IMessaging>(); | ||
77 | messaging.SetListener(listener); | ||
78 | |||
79 | if (warningsAsErrors) | ||
80 | { | ||
81 | messaging.WarningsAsError = true; | ||
82 | } | ||
83 | |||
84 | var arguments = coreProvider.GetService<ICommandLineArguments>(); | ||
85 | arguments.Populate(args); | ||
86 | |||
87 | var commandLine = HeatCommandLineFactory.CreateCommandLine(coreProvider); | ||
88 | var command = commandLine.ParseStandardCommandLine(arguments); | ||
89 | return command?.ExecuteAsync(CancellationToken.None) ?? Task.FromResult(1); | ||
90 | } | ||
91 | } | ||
92 | } | ||
diff --git a/src/tools/test/WixToolsetTest.Heat/WixToolsetTest.Heat.csproj b/src/tools/test/WixToolsetTest.Heat/WixToolsetTest.Heat.csproj new file mode 100644 index 00000000..73eb078c --- /dev/null +++ b/src/tools/test/WixToolsetTest.Heat/WixToolsetTest.Heat.csproj | |||
@@ -0,0 +1,20 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | ||
2 | <!-- 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. --> | ||
3 | |||
4 | <Project Sdk="Microsoft.NET.Sdk"> | ||
5 | <PropertyGroup> | ||
6 | <TargetFramework>netcoreapp3.1</TargetFramework> | ||
7 | <IsPackable>false</IsPackable> | ||
8 | <SignOutput>false</SignOutput> | ||
9 | </PropertyGroup> | ||
10 | |||
11 | <ItemGroup> | ||
12 | <PackageReference Include="WixBuildTools.TestSupport" /> | ||
13 | </ItemGroup> | ||
14 | |||
15 | <ItemGroup> | ||
16 | <PackageReference Include="Microsoft.NET.Test.Sdk" /> | ||
17 | <PackageReference Include="xunit" /> | ||
18 | <PackageReference Include="xunit.runner.visualstudio" PrivateAssets="All" /> | ||
19 | </ItemGroup> | ||
20 | </Project> | ||