From 3abf00a71151d1caef6e853a2f330d7691f4abf8 Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Thu, 24 Apr 2025 21:32:49 -0400 Subject: Remove deprecated Heat. Fixes https://github.com/wixtoolset/issues/issues/9039 --- src/tools/WixToolset.HeatTasks/HeatDirectory.cs | 48 ---------- src/tools/WixToolset.HeatTasks/HeatFile.cs | 45 --------- src/tools/WixToolset.HeatTasks/HeatProject.cs | 73 --------------- src/tools/WixToolset.HeatTasks/HeatTask.cs | 52 ----------- .../RefreshBundleGeneratedFile.cs | 104 --------------------- .../WixToolset.HeatTasks/RefreshGeneratedFile.cs | 91 ------------------ src/tools/WixToolset.HeatTasks/RefreshTask.cs | 59 ------------ .../WixToolset.HeatTasks.csproj | 17 ---- 8 files changed, 489 deletions(-) delete mode 100644 src/tools/WixToolset.HeatTasks/HeatDirectory.cs delete mode 100644 src/tools/WixToolset.HeatTasks/HeatFile.cs delete mode 100644 src/tools/WixToolset.HeatTasks/HeatProject.cs delete mode 100644 src/tools/WixToolset.HeatTasks/HeatTask.cs delete mode 100644 src/tools/WixToolset.HeatTasks/RefreshBundleGeneratedFile.cs delete mode 100644 src/tools/WixToolset.HeatTasks/RefreshGeneratedFile.cs delete mode 100644 src/tools/WixToolset.HeatTasks/RefreshTask.cs delete mode 100644 src/tools/WixToolset.HeatTasks/WixToolset.HeatTasks.csproj (limited to 'src/tools/WixToolset.HeatTasks') diff --git a/src/tools/WixToolset.HeatTasks/HeatDirectory.cs b/src/tools/WixToolset.HeatTasks/HeatDirectory.cs deleted file mode 100644 index 14a8acfa..00000000 --- a/src/tools/WixToolset.HeatTasks/HeatDirectory.cs +++ /dev/null @@ -1,48 +0,0 @@ -// 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.HeatTasks -{ - using Microsoft.Build.Framework; - using WixToolset.BaseBuildTasks; - - public sealed class HeatDirectory : HeatTask - { - public string ComponentGroupName { get; set; } - - [Required] - public string Directory { get; set; } - - public string DirectoryRefId { get; set; } - - public bool KeepEmptyDirectories { get; set; } - - public string PreprocessorVariable { get; set; } - - public bool SuppressCom { get; set; } - - public bool SuppressRootDirectory { get; set; } - - public bool SuppressRegistry { get; set; } - - public string Template { get; set; } - - protected override string OperationName => "dir"; - - protected override void BuildCommandLine(WixCommandLineBuilder commandLineBuilder) - { - commandLineBuilder.AppendSwitch(this.OperationName); - commandLineBuilder.AppendFileNameIfNotNull(this.Directory); - - commandLineBuilder.AppendSwitchIfNotNull("-cg ", this.ComponentGroupName); - commandLineBuilder.AppendSwitchIfNotNull("-dr ", this.DirectoryRefId); - commandLineBuilder.AppendIfTrue("-ke", this.KeepEmptyDirectories); - commandLineBuilder.AppendIfTrue("-scom", this.SuppressCom); - commandLineBuilder.AppendIfTrue("-sreg", this.SuppressRegistry); - commandLineBuilder.AppendIfTrue("-srd", this.SuppressRootDirectory); - commandLineBuilder.AppendSwitchIfNotNull("-template ", this.Template); - commandLineBuilder.AppendSwitchIfNotNull("-var ", this.PreprocessorVariable); - - base.BuildCommandLine(commandLineBuilder); - } - } -} diff --git a/src/tools/WixToolset.HeatTasks/HeatFile.cs b/src/tools/WixToolset.HeatTasks/HeatFile.cs deleted file mode 100644 index b39de7da..00000000 --- a/src/tools/WixToolset.HeatTasks/HeatFile.cs +++ /dev/null @@ -1,45 +0,0 @@ -// 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.HeatTasks -{ - using Microsoft.Build.Framework; - using WixToolset.BaseBuildTasks; - - public sealed class HeatFile : HeatTask - { - public string ComponentGroupName { get; set; } - - public string DirectoryRefId { get; set; } - - [Required] - public string File { get; set; } - - public string PreprocessorVariable { get; set; } - - public bool SuppressCom { get; set; } - - public bool SuppressRegistry { get; set; } - - public bool SuppressRootDirectory { get; set; } - - public string Template { get; set; } - - protected override string OperationName => "file"; - - protected override void BuildCommandLine(WixCommandLineBuilder commandLineBuilder) - { - commandLineBuilder.AppendSwitch(this.OperationName); - commandLineBuilder.AppendFileNameIfNotNull(this.File); - - commandLineBuilder.AppendSwitchIfNotNull("-cg ", this.ComponentGroupName); - commandLineBuilder.AppendSwitchIfNotNull("-dr ", this.DirectoryRefId); - commandLineBuilder.AppendIfTrue("-scom", this.SuppressCom); - commandLineBuilder.AppendIfTrue("-srd", this.SuppressRootDirectory); - commandLineBuilder.AppendIfTrue("-sreg", this.SuppressRegistry); - commandLineBuilder.AppendSwitchIfNotNull("-template ", this.Template); - commandLineBuilder.AppendSwitchIfNotNull("-var ", this.PreprocessorVariable); - - base.BuildCommandLine(commandLineBuilder); - } - } -} diff --git a/src/tools/WixToolset.HeatTasks/HeatProject.cs b/src/tools/WixToolset.HeatTasks/HeatProject.cs deleted file mode 100644 index 998c14ab..00000000 --- a/src/tools/WixToolset.HeatTasks/HeatProject.cs +++ /dev/null @@ -1,73 +0,0 @@ -// 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.HeatTasks -{ - using Microsoft.Build.Framework; - using WixToolset.BaseBuildTasks; - - public sealed class HeatProject : HeatTask - { - private string[] projectOutputGroups; - - public string Configuration { get; set; } - - public string DirectoryIds { get; set; } - - public bool GenerateWixVariables { get; set; } - - public string GenerateType { get; set; } - - public string MsbuildBinPath { get; set; } - - public string Platform { get; set; } - - [Required] - public string Project { get; set; } - - public string ProjectName { get; set; } - - public string[] ProjectOutputGroups - { - get - { - return this.projectOutputGroups; - } - set - { - this.projectOutputGroups = value; - - // If it's just one string and it contains semicolons, let's - // split it into separate items. - if (this.projectOutputGroups.Length == 1) - { - this.projectOutputGroups = this.projectOutputGroups[0].Split(new char[] { ';' }); - } - } - } - - public bool UseToolsVersion { get; set; } - - protected override string OperationName => "project"; - - protected override void BuildCommandLine(WixCommandLineBuilder commandLineBuilder) - { - commandLineBuilder.AppendSwitch(this.OperationName); - commandLineBuilder.AppendFileNameIfNotNull(this.Project); - - commandLineBuilder.AppendSwitchIfNotNull("-configuration ", this.Configuration); - commandLineBuilder.AppendSwitchIfNotNull("-directoryid ", this.DirectoryIds); - commandLineBuilder.AppendSwitchIfNotNull("-generate ", this.GenerateType); - commandLineBuilder.AppendSwitchIfNotNull("-msbuildbinpath ", this.MsbuildBinPath); - commandLineBuilder.AppendSwitchIfNotNull("-platform ", this.Platform); - commandLineBuilder.AppendArrayIfNotNull("-pog ", this.ProjectOutputGroups); - commandLineBuilder.AppendSwitchIfNotNull("-projectname ", this.ProjectName); - commandLineBuilder.AppendIfTrue("-wixvar", this.GenerateWixVariables); - -#if !NETCOREAPP - commandLineBuilder.AppendIfTrue("-usetoolsversion", this.UseToolsVersion); -#endif - - base.BuildCommandLine(commandLineBuilder); - } - } -} diff --git a/src/tools/WixToolset.HeatTasks/HeatTask.cs b/src/tools/WixToolset.HeatTasks/HeatTask.cs deleted file mode 100644 index cad6635b..00000000 --- a/src/tools/WixToolset.HeatTasks/HeatTask.cs +++ /dev/null @@ -1,52 +0,0 @@ -// 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.HeatTasks -{ - using Microsoft.Build.Framework; - using WixToolset.BaseBuildTasks; - - /// - /// A base MSBuild task to run the WiX harvester. - /// Specific harvester tasks should extend this class. - /// - public abstract partial class HeatTask : BaseToolsetTask - { - public bool AutogenerateGuids { get; set; } - - public bool GenerateGuidsNow { get; set; } - - [Required] - [Output] - public ITaskItem OutputFile { get; set; } - - public bool SuppressFragments { get; set; } - - public bool SuppressUniqueIds { get; set; } - - public string[] Transforms { get; set; } - - /// - /// 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; } - - protected sealed override string ToolName => "heat.exe"; - - /// - /// 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("-sfrag", this.SuppressFragments); - commandLineBuilder.AppendIfTrue("-suid", this.SuppressUniqueIds); - commandLineBuilder.AppendArrayIfNotNull("-t ", this.Transforms); - commandLineBuilder.AppendSwitchIfNotNull("-out ", this.OutputFile); - } - } -} diff --git a/src/tools/WixToolset.HeatTasks/RefreshBundleGeneratedFile.cs b/src/tools/WixToolset.HeatTasks/RefreshBundleGeneratedFile.cs deleted file mode 100644 index 8f1ad167..00000000 --- a/src/tools/WixToolset.HeatTasks/RefreshBundleGeneratedFile.cs +++ /dev/null @@ -1,104 +0,0 @@ -// 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.HeatTasks -{ - using System; - using System.Collections; - using System.Globalization; - using System.IO; - using System.Xml; - using Microsoft.Build.Framework; - - /// - /// This task refreshes the generated file for bundle projects. - /// - public class RefreshBundleGeneratedFile : RefreshTask - { - /// - /// Gets a complete list of external cabs referenced by the given installer database file. - /// - /// True upon completion of the task execution. - public override bool Execute() - { - var payloadGroupRefs = new ArrayList(); - var packageGroupRefs = new ArrayList(); - for (var i = 0; i < this.ProjectReferencePaths.Length; i++) - { - var item = this.ProjectReferencePaths[i]; - - if (!String.IsNullOrEmpty(item.GetMetadata(DoNotHarvest))) - { - continue; - } - - var projectPath = item.GetMetadata("MSBuildSourceProjectFile"); - var projectName = Path.GetFileNameWithoutExtension(projectPath); - var referenceName = GetIdentifierFromName(GetMetadataOrDefault(item, "Name", projectName)); - - var pogs = item.GetMetadata("RefProjectOutputGroups").Split(';'); - foreach (var pog in pogs) - { - if (!String.IsNullOrEmpty(pog)) - { - // TODO: Add payload group references and package group references once heat is generating them - ////payloadGroupRefs.Add(String.Format(CultureInfo.InvariantCulture, "{0}.{1}", referenceName, pog)); - packageGroupRefs.Add(String.Format(CultureInfo.InvariantCulture, "{0}.{1}", referenceName, pog)); - } - } - } - - var doc = new XmlDocument(); - - var head = doc.CreateProcessingInstruction("xml", "version='1.0' encoding='UTF-8'"); - doc.AppendChild(head); - - var rootElement = doc.CreateElement("Wix"); - rootElement.SetAttribute("xmlns", "http://wixtoolset.org/schemas/v4/wxs"); - doc.AppendChild(rootElement); - - var fragment = doc.CreateElement("Fragment"); - rootElement.AppendChild(fragment); - - var payloadGroup = doc.CreateElement("PayloadGroup"); - payloadGroup.SetAttribute("Id", "Bundle.Generated.Payloads"); - fragment.AppendChild(payloadGroup); - - var packageGroup = doc.CreateElement("PackageGroup"); - packageGroup.SetAttribute("Id", "Bundle.Generated.Packages"); - fragment.AppendChild(packageGroup); - - foreach (string payloadGroupRef in payloadGroupRefs) - { - var payloadGroupRefElement = doc.CreateElement("PayloadGroupRef"); - payloadGroupRefElement.SetAttribute("Id", payloadGroupRef); - payloadGroup.AppendChild(payloadGroupRefElement); - } - - foreach (string packageGroupRef in packageGroupRefs) - { - var packageGroupRefElement = doc.CreateElement("PackageGroupRef"); - packageGroupRefElement.SetAttribute("Id", packageGroupRef); - packageGroup.AppendChild(packageGroupRefElement); - } - - foreach (var item in this.GeneratedFiles) - { - var fullPath = item.GetMetadata("FullPath"); - - payloadGroup.SetAttribute("Id", Path.GetFileNameWithoutExtension(fullPath) + ".Payloads"); - packageGroup.SetAttribute("Id", Path.GetFileNameWithoutExtension(fullPath) + ".Packages"); - try - { - doc.Save(fullPath); - } - catch (Exception e) - { - // e.Message will be something like: "Access to the path 'fullPath' is denied." - this.Log.LogMessage(MessageImportance.High, "Unable to save generated file to '{0}'. {1}", fullPath, e.Message); - } - } - - return true; - } - } -} diff --git a/src/tools/WixToolset.HeatTasks/RefreshGeneratedFile.cs b/src/tools/WixToolset.HeatTasks/RefreshGeneratedFile.cs deleted file mode 100644 index 1e43cc1f..00000000 --- a/src/tools/WixToolset.HeatTasks/RefreshGeneratedFile.cs +++ /dev/null @@ -1,91 +0,0 @@ -// 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.HeatTasks -{ - using System; - using System.Collections; - using System.Globalization; - using System.IO; - using System.Xml; - using Microsoft.Build.Framework; - - /// - /// This task refreshes the generated file that contains ComponentGroupRefs - /// to harvested output. - /// - public class RefreshGeneratedFile : RefreshTask - { - /// - /// Gets a complete list of external cabs referenced by the given installer database file. - /// - /// True upon completion of the task execution. - public override bool Execute() - { - var componentGroupRefs = new ArrayList(); - - for (var i = 0; i < this.ProjectReferencePaths.Length; i++) - { - var item = this.ProjectReferencePaths[i]; - - if (!String.IsNullOrEmpty(item.GetMetadata(DoNotHarvest))) - { - continue; - } - - var projectPath = item.GetMetadata("MSBuildSourceProjectFile"); - var projectName = Path.GetFileNameWithoutExtension(projectPath); - var referenceName = GetIdentifierFromName(GetMetadataOrDefault(item, "Name", projectName)); - - var pogs = item.GetMetadata("RefProjectOutputGroups").Split(';'); - foreach (var pog in pogs) - { - if (!String.IsNullOrEmpty(pog)) - { - componentGroupRefs.Add(String.Format(CultureInfo.InvariantCulture, "{0}.{1}", referenceName, pog)); - } - } - } - - var doc = new XmlDocument(); - - var head = doc.CreateProcessingInstruction("xml", "version='1.0' encoding='UTF-8'"); - doc.AppendChild(head); - - var rootElement = doc.CreateElement("Wix"); - rootElement.SetAttribute("xmlns", "http://wixtoolset.org/schemas/v4/wxs"); - doc.AppendChild(rootElement); - - var fragment = doc.CreateElement("Fragment"); - rootElement.AppendChild(fragment); - - var componentGroup = doc.CreateElement("ComponentGroup"); - componentGroup.SetAttribute("Id", "Product.Generated"); - fragment.AppendChild(componentGroup); - - foreach (string componentGroupRef in componentGroupRefs) - { - var componentGroupRefElement = doc.CreateElement("ComponentGroupRef"); - componentGroupRefElement.SetAttribute("Id", componentGroupRef); - componentGroup.AppendChild(componentGroupRefElement); - } - - foreach (var item in this.GeneratedFiles) - { - var fullPath = item.GetMetadata("FullPath"); - - componentGroup.SetAttribute("Id", Path.GetFileNameWithoutExtension(fullPath)); - try - { - doc.Save(fullPath); - } - catch (Exception e) - { - // e.Message will be something like: "Access to the path 'fullPath' is denied." - this.Log.LogMessage(MessageImportance.High, "Unable to save generated file to '{0}'. {1}", fullPath, e.Message); - } - } - - return true; - } - } -} diff --git a/src/tools/WixToolset.HeatTasks/RefreshTask.cs b/src/tools/WixToolset.HeatTasks/RefreshTask.cs deleted file mode 100644 index 0b378272..00000000 --- a/src/tools/WixToolset.HeatTasks/RefreshTask.cs +++ /dev/null @@ -1,59 +0,0 @@ -// 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.HeatTasks -{ - using System; - using System.Text.RegularExpressions; - using Microsoft.Build.Framework; - using Microsoft.Build.Utilities; - - /// - /// A base MSBuild task to refresh generated files. - /// - public abstract class RefreshTask : Task - { - private static readonly Regex AddPrefix = new Regex(@"^[^a-zA-Z_]"); - private static readonly Regex IllegalIdentifierCharacters = new Regex(@"[^A-Za-z0-9_\.]|\.{2,}"); // non 'words' and assorted valid characters - - /// Metadata key name to turn off harvesting of project references. - protected const string DoNotHarvest = "DoNotHarvest"; - - /// - /// The list of files to generate. - /// - [Required] - public ITaskItem[] GeneratedFiles { get; set; } - - /// - /// All the project references in the project. - /// - [Required] - public ITaskItem[] ProjectReferencePaths { get; set; } - - /// - /// Return an identifier based on passed file/directory name - /// - /// File/directory name to generate identifer from - /// A version of the name that is a legal identifier. - /// This is duplicated from WiX's Common class. - protected static string GetIdentifierFromName(string name) - { - var result = IllegalIdentifierCharacters.Replace(name, "_"); // replace illegal characters with "_". - - // MSI identifiers must begin with an alphabetic character or an - // underscore. Prefix all other values with an underscore. - if (AddPrefix.IsMatch(name)) - { - result = String.Concat("_", result); - } - - return result; - } - - protected static string GetMetadataOrDefault(ITaskItem item, string metadataName, string defaultValue) - { - var value = item.GetMetadata(metadataName); - return String.IsNullOrWhiteSpace(value) ? defaultValue : value; - } - } -} diff --git a/src/tools/WixToolset.HeatTasks/WixToolset.HeatTasks.csproj b/src/tools/WixToolset.HeatTasks/WixToolset.HeatTasks.csproj deleted file mode 100644 index 21460810..00000000 --- a/src/tools/WixToolset.HeatTasks/WixToolset.HeatTasks.csproj +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - net6.0;net472 - WiX Toolset Heat MSBuild Tasks - embedded - true - AnyCPU - - - - - - - -- cgit v1.2.3-55-g6feb