aboutsummaryrefslogtreecommitdiff
path: root/src/heat/Program.cs
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2020-05-22 20:09:02 +1000
committerSean Hall <r.sean.hall@gmail.com>2020-05-22 20:31:54 +1000
commit929f43b2d48f9d35803064774e357c7a2cf76713 (patch)
tree884bf82e0cdaa8bcf3312c5047702666d8db6121 /src/heat/Program.cs
parent36ed678790b0eb9d39848bf6b384733e57a37b6d (diff)
downloadwix-929f43b2d48f9d35803064774e357c7a2cf76713.tar.gz
wix-929f43b2d48f9d35803064774e357c7a2cf76713.tar.bz2
wix-929f43b2d48f9d35803064774e357c7a2cf76713.zip
Add heat.exe
Diffstat (limited to 'src/heat/Program.cs')
-rw-r--r--src/heat/Program.cs74
1 files changed, 74 insertions, 0 deletions
diff --git a/src/heat/Program.cs b/src/heat/Program.cs
new file mode 100644
index 00000000..38d6d401
--- /dev/null
+++ b/src/heat/Program.cs
@@ -0,0 +1,74 @@
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
3namespace WixToolset.Tools.Heat
4{
5 using System;
6 using System.Runtime.InteropServices;
7 using WixToolset.Core;
8 using WixToolset.Data;
9 using WixToolset.Extensibility;
10 using WixToolset.Extensibility.Data;
11 using WixToolset.Extensibility.Services;
12 using WixToolset.Harvesters;
13 using WixToolset.Tools.Core;
14
15 /// <summary>
16 /// Wix Toolset Harvester.
17 /// </summary>
18 public sealed class Program
19 {
20 /// <summary>
21 /// The main entry point for the application.
22 /// </summary>
23 /// <param name="args">Commandline arguments for the application.</param>
24 /// <returns>Returns the application error code.</returns>
25 [MTAThread]
26 public static int Main(string[] args)
27 {
28 var serviceProvider = WixToolsetServiceProviderFactory.CreateServiceProvider();
29 var listener = new ConsoleMessageListener("HEAT", "heat.exe");
30
31 try
32 {
33 var program = new Program();
34 return program.Run(serviceProvider, listener, args);
35 }
36 catch (WixException e)
37 {
38 listener.Write(e.Error);
39
40 return e.Error.Id;
41 }
42 catch (Exception e)
43 {
44 listener.Write(ErrorMessages.UnexpectedException(e));
45
46 if (e is NullReferenceException || e is SEHException)
47 {
48 throw;
49 }
50
51 return e.HResult;
52 }
53 }
54
55 /// <summary>
56 /// Run the application with the given arguments.
57 /// </summary>
58 /// <param name="serviceProvider">Service provider to use throughout this execution.</param>
59 /// <param name="args">The commandline arguments.</param>
60 /// <returns>Returns the application error code.</returns>
61 public int Run(IWixToolsetServiceProvider serviceProvider, IMessageListener listener, string[] args)
62 {
63 var messaging = serviceProvider.GetService<IMessaging>();
64 messaging.SetListener(listener);
65
66 var arguments = serviceProvider.GetService<ICommandLineArguments>();
67 arguments.Populate(args);
68
69 var commandLine = HeatCommandLineFactory.CreateCommandLine(serviceProvider);
70 var command = commandLine.ParseStandardCommandLine(arguments);
71 return command?.Execute() ?? 1;
72 }
73 }
74}