From 929f43b2d48f9d35803064774e357c7a2cf76713 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Fri, 22 May 2020 20:09:02 +1000 Subject: Add heat.exe --- src/heat/Program.cs | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 src/heat/Program.cs (limited to 'src/heat/Program.cs') 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 @@ +// 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. + +namespace WixToolset.Tools.Heat +{ + using System; + using System.Runtime.InteropServices; + using WixToolset.Core; + using WixToolset.Data; + using WixToolset.Extensibility; + using WixToolset.Extensibility.Data; + using WixToolset.Extensibility.Services; + using WixToolset.Harvesters; + using WixToolset.Tools.Core; + + /// + /// Wix Toolset Harvester. + /// + public sealed class Program + { + /// + /// The main entry point for the application. + /// + /// Commandline arguments for the application. + /// Returns the application error code. + [MTAThread] + public static int Main(string[] args) + { + var serviceProvider = WixToolsetServiceProviderFactory.CreateServiceProvider(); + var listener = new ConsoleMessageListener("HEAT", "heat.exe"); + + try + { + var program = new Program(); + return program.Run(serviceProvider, listener, args); + } + catch (WixException e) + { + listener.Write(e.Error); + + return e.Error.Id; + } + catch (Exception e) + { + listener.Write(ErrorMessages.UnexpectedException(e)); + + if (e is NullReferenceException || e is SEHException) + { + throw; + } + + return e.HResult; + } + } + + /// + /// Run the application with the given arguments. + /// + /// Service provider to use throughout this execution. + /// The commandline arguments. + /// Returns the application error code. + public int Run(IWixToolsetServiceProvider serviceProvider, IMessageListener listener, string[] args) + { + var messaging = serviceProvider.GetService(); + messaging.SetListener(listener); + + var arguments = serviceProvider.GetService(); + arguments.Populate(args); + + var commandLine = HeatCommandLineFactory.CreateCommandLine(serviceProvider); + var command = commandLine.ParseStandardCommandLine(arguments); + return command?.Execute() ?? 1; + } + } +} -- cgit v1.2.3-55-g6feb