From 306f1d0c528cb6c151594ff96a41b5c01a5c4d9b Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Sat, 21 Jul 2018 07:36:34 -0700 Subject: Integrate tools from Core project --- src/WixToolset.BuildTasks/HeatTask.cs | 121 ++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 src/WixToolset.BuildTasks/HeatTask.cs (limited to 'src/WixToolset.BuildTasks/HeatTask.cs') diff --git a/src/WixToolset.BuildTasks/HeatTask.cs b/src/WixToolset.BuildTasks/HeatTask.cs new file mode 100644 index 00000000..bf0a2ad3 --- /dev/null +++ b/src/WixToolset.BuildTasks/HeatTask.cs @@ -0,0 +1,121 @@ +// 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.BuildTasks +{ + using System; + using System.Diagnostics; + using System.Globalization; + using System.IO; + using System.Text; + + using Microsoft.Build.Framework; + using Microsoft.Build.Utilities; + + /// + /// A base MSBuild task to run the WiX harvester. + /// Specific harvester tasks should extend this class. + /// + public abstract class HeatTask : WixToolTask + { + private const string HeatToolName = "Heat.exe"; + + private bool autogenerageGuids; + private bool generateGuidsNow; + private ITaskItem outputFile; + private bool suppressFragments; + private bool suppressUniqueIds; + private string[] transforms; + + public bool AutogenerateGuids + { + get { return this.autogenerageGuids; } + set { this.autogenerageGuids = value; } + } + + public bool GenerateGuidsNow + { + get { return this.generateGuidsNow; } + set { this.generateGuidsNow = value; } + } + + [Required] + [Output] + public ITaskItem OutputFile + { + get { return this.outputFile; } + set { this.outputFile = value; } + } + + public bool SuppressFragments + { + get { return this.suppressFragments; } + set { this.suppressFragments = value; } + } + + public bool SuppressUniqueIds + { + get { return this.suppressUniqueIds; } + set { this.suppressUniqueIds = value; } + } + + public string[] Transforms + { + get { return this.transforms; } + set { this.transforms = value; } + } + + /// + /// Get the name of the executable. + /// + /// The ToolName is used with the ToolPath to get the location of heat.exe. + /// The name of the executable. + protected override string ToolName + { + get { return HeatToolName; } + } + + /// + /// Gets the name of the heat operation performed by the task. + /// + /// This is the first parameter passed on the heat.exe command-line. + /// The name of the heat operation performed by the task. + protected abstract string OperationName + { + get; + } + + /// + /// Get the path to the executable. + /// + /// GetFullPathToTool is only called when the ToolPath property is not set (see the ToolName remarks above). + /// The full path to the executable or simply heat.exe if it's expected to be in the system path. + protected override string GenerateFullPathToTool() + { + // If there's not a ToolPath specified, it has to be in the system path. + if (String.IsNullOrEmpty(this.ToolPath)) + { + return HeatToolName; + } + + return Path.Combine(Path.GetFullPath(this.ToolPath), HeatToolName); + } + + /// + /// Builds a command line from options in this task. + /// + protected override void BuildCommandLine(WixCommandLineBuilder commandLineBuilder) + { + base.BuildCommandLine(commandLineBuilder); + + commandLineBuilder.AppendIfTrue("-ag", this.AutogenerateGuids); + commandLineBuilder.AppendIfTrue("-gg", this.GenerateGuidsNow); + commandLineBuilder.AppendIfTrue("-nologo", this.NoLogo); + commandLineBuilder.AppendIfTrue("-sfrag", this.SuppressFragments); + commandLineBuilder.AppendIfTrue("-suid", this.SuppressUniqueIds); + commandLineBuilder.AppendArrayIfNotNull("-sw", this.SuppressSpecificWarnings); + commandLineBuilder.AppendArrayIfNotNull("-t ", this.Transforms); + commandLineBuilder.AppendTextIfNotNull(this.AdditionalOptions); + commandLineBuilder.AppendSwitchIfNotNull("-out ", this.OutputFile); + } + } +} -- cgit v1.2.3-55-g6feb