From 35606d2cd04a7b1bec1d669f9619501dff2bf9dc Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Thu, 22 Apr 2021 17:38:36 -0700 Subject: Simplify heat by creating a single executable --- src/heat/Data/HarvesterErrors.cs | 205 +++++++++++++++++++++++++++++++++ src/heat/Data/HarvesterVerboses.cs | 62 ++++++++++ src/heat/Data/HarvesterWarnings.cs | 79 +++++++++++++ src/heat/Data/HeatCommandLineOption.cs | 31 +++++ src/heat/Data/IHeatCommandLine.cs | 12 ++ 5 files changed, 389 insertions(+) create mode 100644 src/heat/Data/HarvesterErrors.cs create mode 100644 src/heat/Data/HarvesterVerboses.cs create mode 100644 src/heat/Data/HarvesterWarnings.cs create mode 100644 src/heat/Data/HeatCommandLineOption.cs create mode 100644 src/heat/Data/IHeatCommandLine.cs (limited to 'src/heat/Data') diff --git a/src/heat/Data/HarvesterErrors.cs b/src/heat/Data/HarvesterErrors.cs new file mode 100644 index 00000000..a8a3055a --- /dev/null +++ b/src/heat/Data/HarvesterErrors.cs @@ -0,0 +1,205 @@ +// 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.Harvesters.Data +{ + using System; + using System.Resources; + using WixToolset.Data; + +#pragma warning disable 1591 // TODO: add documentation + public static class HarvesterErrors + { + public static Message ArgumentRequiresValue(string argument) + { + return Message(null, Ids.ArgumentRequiresValue, "The argument '{0}' does not have a value specified and it is required.", argument); + } + + public static Message BuildErrorDuringHarvesting(string buildError) + { + return Message(null, Ids.BuildErrorDuringHarvesting, "Build error during harvesting: {0}", buildError); + } + + public static Message BuildFailed() + { + return Message(null, Ids.BuildFailed, "Build failed."); + } + + public static Message CannotBuildProject(string projectFile, string innerExceptionMessage) + { + return Message(null, Ids.CannotBuildProject, "Failed to build project {0}: {1}", projectFile, innerExceptionMessage); + } + + public static Message CannotHarvestWebSite() + { + return Message(null, Ids.CannotHarvestWebSite, "Cannot harvest website. On Windows Vista, you must install IIS 6 Management Compatibility."); + } + + public static Message CannotLoadMSBuildAssembly(string innerExceptionMessage) + { + return Message(null, Ids.CannotLoadMSBuildAssembly, "Failed to load MSBuild assembly: {0}", innerExceptionMessage); + } + + public static Message CannotLoadMSBuildEngine(string innerExceptionMessage) + { + return Message(null, Ids.CannotLoadMSBuildEngine, "Failed to load MSBuild engine: {0}", innerExceptionMessage); + } + + public static Message CannotLoadMSBuildWrapperAssembly(string innerExceptionMessage) + { + return Message(null, Ids.CannotLoadMSBuildWrapperAssembly, "Failed to load MSBuild wrapper assembly: {0}", innerExceptionMessage); + } + + public static Message CannotLoadMSBuildWrapperObject(string innerExceptionMessage) + { + return Message(null, Ids.CannotLoadMSBuildWrapperObject, "Failed to load MSBuild wrapper object: {0}", innerExceptionMessage); + } + + public static Message CannotLoadMSBuildWrapperType(string innerExceptionMessage) + { + return Message(null, Ids.CannotLoadMSBuildWrapperType, "Failed to load MSBuild wrapper type: {0}", innerExceptionMessage); + } + + public static Message CannotLoadProject(string projectFile, string innerExceptionMessage) + { + return Message(null, Ids.CannotLoadProject, "Failed to load project {0}: {1}", projectFile, innerExceptionMessage); + } + + public static Message DirectoryAttributeAccessorBadType(string attributeName) + { + return Message(null, Ids.DirectoryAttributeAccessorBadType, "DirectoryAttributeAccessor tried to access an invalid element type for attribute '{0'}.", attributeName); + } + + public static Message DirectoryNotFound(string directory) + { + return Message(null, Ids.DirectoryNotFound, "The directory '{0}' could not be found.", directory); + } + + public static Message EmptyDirectory(string directory) + { + return Message(null, Ids.EmptyDirectory, "The directory '{0}' did not contain any files or sub-directories and since empty directories are not being kept, there was nothing to harvest.", directory); + } + + public static Message ErrorTransformingHarvestedWiX(string transform, string message) + { + return Message(null, Ids.ErrorTransformingHarvestedWiX, "Error applying transform {0} to harvested WiX: {1}", transform, message); + } + + public static Message FileNotFound(string file) + { + return Message(null, Ids.FileNotFound, "The file '{0}' cannot be found.", file); + } + + public static Message InsufficientPermissionHarvestWebSite() + { + return Message(null, Ids.InsufficientPermissionHarvestWebSite, "Not enough permissions to harvest website. On Windows Vista, you must run Heat elevated."); + } + + public static Message InvalidDirectoryId(string generateType) + { + return Message(null, Ids.InvalidDirectoryId, "Invalid directory ID: {0}. Check that it doesn't start with a hyphen or slash.", generateType); + } + + public static Message InvalidDirectoryOutputType(string generateType) + { + return Message(null, Ids.InvalidOutputType, "Invalid generated type: {0}. Must be one of: components, payloadgroup.", generateType); + } + + public static Message InvalidOutputGroup(string outputGroup) + { + return Message(null, Ids.InvalidOutputGroup, "Invalid project output group: {0}.", outputGroup); + } + + public static Message InvalidProjectOutputType(string generateType) + { + return Message(null, Ids.InvalidOutputType, "Invalid generated type: {0}. Must be one of: components, container, payloadgroup, packagegroup.", generateType); + } + + public static Message InvalidProjectName(string generateType) + { + return Message(null, Ids.InvalidProjectName, "Invalid project name: {0}. Check that it doesn't start with a hyphen or slash.", generateType); + } + + public static Message MissingProjectOutputGroup(string projectFile, string outputGroup) + { + return Message(null, Ids.MissingProjectOutputGroup, "Missing project output group '{1}' in project {0}.", projectFile, outputGroup); + } + + public static Message MsbuildBinPathRequired(string version) + { + return Message(null, Ids.MsbuildBinPathRequired, "MSBuildBinPath required for ToolsVersion '{0}'", version); + } + + public static Message NoOutputGroupSpecified() + { + return Message(null, Ids.NoOutputGroupSpecified, "No project output group specified."); + } + + public static Message PerformanceCategoryNotFound(string key) + { + return Message(null, Ids.PerformanceCategoryNotFound, "Performance category '{0}' not found.", key); + } + + public static Message SpacesNotAllowedInArgumentValue(string arg, string value) + { + return Message(null, Ids.SpacesNotAllowedInArgumentValue, "The switch '{0}' does not allow the spaces from the value. Please remove the spaces in from the value: {1}", arg, value); + } + + public static Message UnableToOpenRegistryKey(string key) + { + return Message(null, Ids.UnableToOpenRegistryKey, "Unable to open registry key '{0}'.", key); + } + + public static Message UnsupportedPerformanceCounterType(string key) + { + return Message(null, Ids.UnsupportedPerformanceCounterType, "Unsupported performance counter type '{0}'.", key); + } + + public static Message WebSiteNotFound(string webSiteDescription) + { + return Message(null, Ids.WebSiteNotFound, "The web site '{0}' could not be found. Please check that the web site exists, and that it is spelled correctly (please note, you must use the correct case).", webSiteDescription); + } + + private static Message Message(SourceLineNumber sourceLineNumber, Ids id, string format, params object[] args) + { + return new Message(sourceLineNumber, MessageLevel.Error, (int)id, format, args); + } + + private static Message Message(SourceLineNumber sourceLineNumber, Ids id, ResourceManager resourceManager, string resourceName, params object[] args) + { + return new Message(sourceLineNumber, MessageLevel.Error, (int)id, resourceManager, resourceName, args); + } + + public enum Ids + { + DirectoryNotFound = 5052, + EmptyDirectory = 5053, + ErrorTransformingHarvestedWiX = 5055, + UnableToOpenRegistryKey = 5056, + SpacesNotAllowedInArgumentValue = 5057, + ArgumentRequiresValue = 5058, + FileNotFound = 5059, + PerformanceCategoryNotFound = 5060, + UnsupportedPerformanceCounterType = 5061, + WebSiteNotFound = 5158, + InsufficientPermissionHarvestWebSite = 5159, + CannotHarvestWebSite = 5160, + InvalidOutputGroup = 5301, + NoOutputGroupSpecified = 5302, + CannotLoadMSBuildAssembly = 5303, + CannotLoadMSBuildEngine = 5304, + CannotLoadProject = 5305, + CannotBuildProject = 5306, + BuildFailed = 5307, + MissingProjectOutputGroup = 5308, + DirectoryAttributeAccessorBadType = 5309, + InvalidOutputType = 5310, + InvalidDirectoryId = 5311, + InvalidProjectName = 5312, + BuildErrorDuringHarvesting = 5313, + CannotLoadMSBuildWrapperAssembly = 5314, + CannotLoadMSBuildWrapperType = 5315, + CannotLoadMSBuildWrapperObject = 5316, + MsbuildBinPathRequired = 5317, + } + } +} diff --git a/src/heat/Data/HarvesterVerboses.cs b/src/heat/Data/HarvesterVerboses.cs new file mode 100644 index 00000000..72de2351 --- /dev/null +++ b/src/heat/Data/HarvesterVerboses.cs @@ -0,0 +1,62 @@ +// 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.Harvesters.Data +{ + using System; + using System.Resources; + using WixToolset.Data; + +#pragma warning disable 1591 // TODO: add documentation + public static class HarvesterVerboses + { + public static Message FoundToolsVersion(string toolsVersion) + { + return Message(null, Ids.FoundToolsVersion, "Found ToolsVersion {0} inside project file.", toolsVersion); + } + + public static Message HarvestingAssembly(string fileName) + { + return Message(null, Ids.HarvestingAssembly, "Trying to harvest {0} as an assembly.", fileName); + } + + public static Message HarvestingSelfReg(string fileName) + { + return Message(null, Ids.HarvestingSelfReg, "Trying to harvest self-registration information from native DLL {0}.", fileName); + } + + public static Message HarvestingTypeLib(string fileName) + { + return Message(null, Ids.HarvestingTypeLib, "Trying to harvest type-library information from native DLL {0}.", fileName); + } + + public static Message LoadingProjectWithBinPath(string msbuildBinPath) + { + return Message(null, Ids.LoadingProjectWithBinPath, "Loading project using MSBuild bin path {0}.", msbuildBinPath); + } + + public static Message LoadingProjectWithVersion(string msbuildVersion) + { + return Message(null, Ids.LoadingProjectWithVersion, "Loading project using MSBuild version {0}.", msbuildVersion); + } + + private static Message Message(SourceLineNumber sourceLineNumber, Ids id, string format, params object[] args) + { + return new Message(sourceLineNumber, MessageLevel.Verbose, (int)id, format, args); + } + + private static Message Message(SourceLineNumber sourceLineNumber, Ids id, ResourceManager resourceManager, string resourceName, params object[] args) + { + return new Message(sourceLineNumber, MessageLevel.Verbose, (int)id, resourceManager, resourceName, args); + } + + public enum Ids + { + HarvestingAssembly = 5100, + HarvestingSelfReg = 5101, + HarvestingTypeLib = 5102, + LoadingProjectWithVersion = 5378, + FoundToolsVersion = 5379, + LoadingProjectWithBinPath = 5380, + } + } +} diff --git a/src/heat/Data/HarvesterWarnings.cs b/src/heat/Data/HarvesterWarnings.cs new file mode 100644 index 00000000..80ee5c31 --- /dev/null +++ b/src/heat/Data/HarvesterWarnings.cs @@ -0,0 +1,79 @@ +// 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.Harvesters.Data +{ + using System; + using System.Resources; + using WixToolset.Data; + +#pragma warning disable 1591 // TODO: add documentation + public static class HarvesterWarnings + { + public static Message AssemblyHarvestFailed(string file, string message) + { + return Message(null, Ids.AssemblyHarvestFailed, "Could not harvest data from a file that was expected to be an assembly: {0}. If this file is not an assembly you can ignore this warning. Otherwise, this error detail may be helpful to diagnose the failure: {1}", file, message); + } + + public static Message DuplicateDllRegistryEntry(string registryKey, string componentId) + { + return Message(null, Ids.DuplicateDllRegistryEntry, "Ignoring the registry key '{0}', it has already been added to the component '{1}'.", registryKey, componentId); + } + + public static Message DuplicateDllRegistryEntry(string registryKey, string registryKeyValue, string componentId) + { + return Message(null, Ids.DuplicateDllRegistryEntry, "Ignoring the registry key '{0}', it has already been added to the component '{2}'. The registry key value '{1}' will not be harvested.", registryKey, registryKeyValue, componentId); + } + + public static Message EncounteredNullDirectoryForWebSite(string directory) + { + return Message(null, Ids.EncounteredNullDirectoryForWebSite, "Could not harvest website directory: {0}. Please update the output with the appropriate directory ID before using.", directory); + } + + public static Message NoLogger(string exceptionMessage) + { + return Message(null, Ids.NoLogger, "Failed to set loggers: {0}", exceptionMessage); + } + + public static Message NoProjectConfiguration(string exceptionMessage) + { + return Message(null, Ids.NoProjectConfiguration, "Failed to set project configuration and platform: {0}", exceptionMessage); + } + + public static Message SelfRegHarvestFailed(string file, string message) + { + return Message(null, Ids.SelfRegHarvestFailed, "Could not harvest data from a file that was expected to be a SelfReg DLL: {0}. If this file does not support SelfReg you can ignore this warning. Otherwise, this error detail may be helpful to diagnose the failure: {1}", file, message); + } + + public static Message TypeLibLoadFailed(string file, string message) + { + return Message(null, Ids.TypeLibLoadFailed, "Could not load file that was expected to be a type library based off of file extension: {0}. If this file is not a type library you can ignore this warning. Otherwise, this error detail may be helpful to diagnose the load failure: {1}", file, message); + } + + public static Message UnsupportedRegistryType(string registryValue, int regFileLineNumber, string unsupportedType) + { + return Message(null, Ids.UnsupportedRegistryType, "Ignoring the registry value '{0}' found on line {1}, because it is of a type unsupported by Windows Installer ({2}).", registryValue, regFileLineNumber, unsupportedType); + } + + private static Message Message(SourceLineNumber sourceLineNumber, Ids id, string format, params object[] args) + { + return new Message(sourceLineNumber, MessageLevel.Warning, (int)id, format, args); + } + + private static Message Message(SourceLineNumber sourceLineNumber, Ids id, ResourceManager resourceManager, string resourceName, params object[] args) + { + return new Message(sourceLineNumber, MessageLevel.Warning, (int)id, resourceManager, resourceName, args); + } + + public enum Ids + { + SelfRegHarvestFailed = 5150, + AssemblyHarvestFailed = 5151, + TypeLibLoadFailed = 5152, + DuplicateDllRegistryEntry = 5156, + UnsupportedRegistryType = 5157, + NoProjectConfiguration = 5398, + NoLogger = 5399, + EncounteredNullDirectoryForWebSite = 5400, + } + } +} diff --git a/src/heat/Data/HeatCommandLineOption.cs b/src/heat/Data/HeatCommandLineOption.cs new file mode 100644 index 00000000..5815abf0 --- /dev/null +++ b/src/heat/Data/HeatCommandLineOption.cs @@ -0,0 +1,31 @@ +// 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.Harvesters.Data +{ + /// + /// A command line option. + /// + public struct HeatCommandLineOption + { + /// + /// The option name used on the command line. + /// + public string Option; + + /// + /// Description shown in Help command. + /// + public string Description; + + /// + /// Instantiates a new CommandLineOption. + /// + /// The option name. + /// The description of the option. + public HeatCommandLineOption(string option, string description) + { + this.Option = option; + this.Description = description; + } + } +} diff --git a/src/heat/Data/IHeatCommandLine.cs b/src/heat/Data/IHeatCommandLine.cs new file mode 100644 index 00000000..9198468d --- /dev/null +++ b/src/heat/Data/IHeatCommandLine.cs @@ -0,0 +1,12 @@ +// 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.Harvesters.Data +{ + using WixToolset.Extensibility.Data; + +#pragma warning disable 1591 // TODO: add documentation + public interface IHeatCommandLine + { + ICommandLineCommand ParseStandardCommandLine(ICommandLineArguments arguments); + } +} -- cgit v1.2.3-55-g6feb