diff options
| author | Rob Mensching <rob@firegiant.com> | 2022-11-08 14:58:05 -0800 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2022-11-08 16:20:25 -0800 |
| commit | c843b47d6233153fa961c6d0e61edf7cedf255bb (patch) | |
| tree | 9eae6badd42d3badb8665b7414b4d44ca48d6ae1 /src/internal/WixToolset.BaseBuildTasks.Sources | |
| parent | 7e498d6348c26583972ea1cdf7d51dadc8f5b792 (diff) | |
| download | wix-c843b47d6233153fa961c6d0e61edf7cedf255bb.tar.gz wix-c843b47d6233153fa961c6d0e61edf7cedf255bb.tar.bz2 wix-c843b47d6233153fa961c6d0e61edf7cedf255bb.zip | |
Separate WixInternal content from official WixToolset namespace
Diffstat (limited to 'src/internal/WixToolset.BaseBuildTasks.Sources')
3 files changed, 0 insertions, 318 deletions
diff --git a/src/internal/WixToolset.BaseBuildTasks.Sources/BaseToolsetTask.cs b/src/internal/WixToolset.BaseBuildTasks.Sources/BaseToolsetTask.cs deleted file mode 100644 index d9e3b5e8..00000000 --- a/src/internal/WixToolset.BaseBuildTasks.Sources/BaseToolsetTask.cs +++ /dev/null | |||
| @@ -1,178 +0,0 @@ | |||
| 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 | |||
| 3 | namespace WixToolset.BaseBuildTasks | ||
| 4 | { | ||
| 5 | using System; | ||
| 6 | using System.IO; | ||
| 7 | using System.Runtime.InteropServices; | ||
| 8 | using Microsoft.Build.Utilities; | ||
| 9 | |||
| 10 | public abstract class BaseToolsetTask : ToolTask | ||
| 11 | { | ||
| 12 | /// <summary> | ||
| 13 | /// Gets or sets additional options that are appended the the tool command-line. | ||
| 14 | /// </summary> | ||
| 15 | /// <remarks> | ||
| 16 | /// This allows the task to support extended options in the tool which are not | ||
| 17 | /// explicitly implemented as properties on the task. | ||
| 18 | /// </remarks> | ||
| 19 | public string AdditionalOptions { get; set; } | ||
| 20 | |||
| 21 | /// <summary> | ||
| 22 | /// Gets or sets whether to display the logo. | ||
| 23 | /// </summary> | ||
| 24 | public bool NoLogo { get; set; } | ||
| 25 | |||
| 26 | /// <summary> | ||
| 27 | /// Gets or sets whether all warnings should be suppressed. | ||
| 28 | /// </summary> | ||
| 29 | public bool SuppressAllWarnings { get; set; } | ||
| 30 | |||
| 31 | /// <summary> | ||
| 32 | /// Gets or sets a list of specific warnings to be suppressed. | ||
| 33 | /// </summary> | ||
| 34 | public string[] SuppressSpecificWarnings { get; set; } | ||
| 35 | |||
| 36 | /// <summary> | ||
| 37 | /// Gets or sets whether all warnings should be treated as errors. | ||
| 38 | /// </summary> | ||
| 39 | public bool TreatWarningsAsErrors { get; set; } | ||
| 40 | |||
| 41 | /// <summary> | ||
| 42 | /// Gets or sets a list of specific warnings to treat as errors. | ||
| 43 | /// </summary> | ||
| 44 | public string[] TreatSpecificWarningsAsErrors { get; set; } | ||
| 45 | |||
| 46 | /// <summary> | ||
| 47 | /// Gets or sets whether to display verbose output. | ||
| 48 | /// </summary> | ||
| 49 | public bool VerboseOutput { get; set; } | ||
| 50 | |||
| 51 | /// <summary> | ||
| 52 | /// Get the path to the executable. | ||
| 53 | /// </summary> | ||
| 54 | /// <remarks> | ||
| 55 | /// ToolTask only calls GenerateFullPathToTool when the ToolPath property is not set. | ||
| 56 | /// WiX never sets the ToolPath property, but the user can through $(WixToolDir). | ||
| 57 | /// If we return only a file name, ToolTask will search the system paths for it. | ||
| 58 | /// </remarks> | ||
| 59 | protected sealed override string GenerateFullPathToTool() | ||
| 60 | { | ||
| 61 | var defaultToolFullPath = this.GetDefaultToolFullPath(); | ||
| 62 | |||
| 63 | #if NETCOREAPP | ||
| 64 | // If we're pointing at an executable use that. | ||
| 65 | if (IsSelfExecutable(defaultToolFullPath, out var finalToolFullPath)) | ||
| 66 | { | ||
| 67 | return finalToolFullPath; | ||
| 68 | } | ||
| 69 | |||
| 70 | // Otherwise, use "dotnet.exe" to run an assembly dll. | ||
| 71 | return Environment.GetEnvironmentVariable("DOTNET_HOST_PATH") ?? "dotnet"; | ||
| 72 | #else | ||
| 73 | return defaultToolFullPath; | ||
| 74 | #endif | ||
| 75 | } | ||
| 76 | |||
| 77 | /// <summary> | ||
| 78 | /// Builds a command line from options in this and derivative tasks. | ||
| 79 | /// </summary> | ||
| 80 | /// <remarks> | ||
| 81 | /// Derivative classes should call BuildCommandLine() on the base class to ensure that common command line options are added to the command. | ||
| 82 | /// </remarks> | ||
| 83 | protected virtual void BuildCommandLine(WixCommandLineBuilder commandLineBuilder) | ||
| 84 | { | ||
| 85 | commandLineBuilder.AppendIfTrue("-nologo", this.NoLogo); | ||
| 86 | commandLineBuilder.AppendArrayIfNotNull("-sw", this.SuppressSpecificWarnings); | ||
| 87 | commandLineBuilder.AppendIfTrue("-sw", this.SuppressAllWarnings); | ||
| 88 | commandLineBuilder.AppendIfTrue("-v", this.VerboseOutput); | ||
| 89 | commandLineBuilder.AppendArrayIfNotNull("-wx", this.TreatSpecificWarningsAsErrors); | ||
| 90 | commandLineBuilder.AppendIfTrue("-wx", this.TreatWarningsAsErrors); | ||
| 91 | commandLineBuilder.AppendTextIfNotNull(this.AdditionalOptions); | ||
| 92 | } | ||
| 93 | |||
| 94 | protected sealed override string GenerateResponseFileCommands() | ||
| 95 | { | ||
| 96 | var commandLineBuilder = new WixCommandLineBuilder(); | ||
| 97 | this.BuildCommandLine(commandLineBuilder); | ||
| 98 | return commandLineBuilder.ToString(); | ||
| 99 | } | ||
| 100 | |||
| 101 | #if NETCOREAPP | ||
| 102 | protected override string GenerateCommandLineCommands() | ||
| 103 | { | ||
| 104 | // If the target tool path is an executable, we don't need to add anything to the command-line. | ||
| 105 | var toolFullPath = this.GetToolFullPath(); | ||
| 106 | |||
| 107 | if (IsSelfExecutable(toolFullPath, out var finalToolFullPath)) | ||
| 108 | { | ||
| 109 | return null; | ||
| 110 | } | ||
| 111 | else // we're using "dotnet.exe" to run the assembly so add "exec" plus path to the command-line. | ||
| 112 | { | ||
| 113 | return $"exec \"{finalToolFullPath}\""; | ||
| 114 | } | ||
| 115 | } | ||
| 116 | |||
| 117 | private static bool IsSelfExecutable(string proposedToolFullPath, out string finalToolFullPath) | ||
| 118 | { | ||
| 119 | var toolFullPathWithoutExtension = Path.Combine(Path.GetDirectoryName(proposedToolFullPath), Path.GetFileNameWithoutExtension(proposedToolFullPath)); | ||
| 120 | var exeExtension = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ".exe" : String.Empty; | ||
| 121 | var exeToolFullPath = $"{toolFullPathWithoutExtension}{exeExtension}"; | ||
| 122 | if (File.Exists(exeToolFullPath)) | ||
| 123 | { | ||
| 124 | finalToolFullPath = exeToolFullPath; | ||
| 125 | return true; | ||
| 126 | } | ||
| 127 | |||
| 128 | finalToolFullPath = $"{toolFullPathWithoutExtension}.dll"; | ||
| 129 | return false; | ||
| 130 | } | ||
| 131 | #else | ||
| 132 | private static string GetArchitectureFolder(string baseFolder) | ||
| 133 | { | ||
| 134 | // First try to find a folder that matches this task's architecture. | ||
| 135 | var folder = RuntimeInformation.ProcessArchitecture.ToString().ToLowerInvariant(); | ||
| 136 | |||
| 137 | if (Directory.Exists(Path.Combine(baseFolder, folder))) | ||
| 138 | { | ||
| 139 | return folder; | ||
| 140 | } | ||
| 141 | |||
| 142 | // Try to fallback to "x86" folder. | ||
| 143 | if (folder != "x86" && Directory.Exists(Path.Combine(baseFolder, "x86"))) | ||
| 144 | { | ||
| 145 | return "x86"; | ||
| 146 | } | ||
| 147 | |||
| 148 | // Return empty, even though this isn't likely to be useful. | ||
| 149 | return String.Empty; | ||
| 150 | } | ||
| 151 | #endif | ||
| 152 | |||
| 153 | private string GetDefaultToolFullPath() | ||
| 154 | { | ||
| 155 | #if NETCOREAPP | ||
| 156 | var thisTaskFolder = Path.GetDirectoryName(typeof(BaseToolsetTask).Assembly.Location); | ||
| 157 | |||
| 158 | return Path.Combine(thisTaskFolder, this.ToolExe); | ||
| 159 | #else | ||
| 160 | var thisTaskFolder = Path.GetDirectoryName(new Uri(typeof(BaseToolsetTask).Assembly.CodeBase).AbsolutePath); | ||
| 161 | |||
| 162 | var archFolder = GetArchitectureFolder(thisTaskFolder); | ||
| 163 | |||
| 164 | return Path.Combine(thisTaskFolder, archFolder, this.ToolExe); | ||
| 165 | #endif | ||
| 166 | } | ||
| 167 | |||
| 168 | private string GetToolFullPath() | ||
| 169 | { | ||
| 170 | if (String.IsNullOrEmpty(this.ToolPath)) | ||
| 171 | { | ||
| 172 | return this.GetDefaultToolFullPath(); | ||
| 173 | } | ||
| 174 | |||
| 175 | return Path.Combine(this.ToolPath, this.ToolExe); | ||
| 176 | } | ||
| 177 | } | ||
| 178 | } | ||
diff --git a/src/internal/WixToolset.BaseBuildTasks.Sources/WixCommandLineBuilder.cs b/src/internal/WixToolset.BaseBuildTasks.Sources/WixCommandLineBuilder.cs deleted file mode 100644 index d950bca9..00000000 --- a/src/internal/WixToolset.BaseBuildTasks.Sources/WixCommandLineBuilder.cs +++ /dev/null | |||
| @@ -1,104 +0,0 @@ | |||
| 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 | |||
| 3 | namespace WixToolset.BaseBuildTasks | ||
| 4 | { | ||
| 5 | using System; | ||
| 6 | using System.Collections.Generic; | ||
| 7 | using System.Globalization; | ||
| 8 | using System.IO; | ||
| 9 | |||
| 10 | using Microsoft.Build.Framework; | ||
| 11 | using Microsoft.Build.Utilities; | ||
| 12 | |||
| 13 | /// <summary> | ||
| 14 | /// Helper class for appending the command line arguments. | ||
| 15 | /// </summary> | ||
| 16 | public class WixCommandLineBuilder : CommandLineBuilder | ||
| 17 | { | ||
| 18 | internal const int Unspecified = -1; | ||
| 19 | |||
| 20 | /// <summary> | ||
| 21 | /// Append a switch to the command line if the value has been specified. | ||
| 22 | /// </summary> | ||
| 23 | /// <param name="switchName">Switch to append.</param> | ||
| 24 | /// <param name="value">Value specified by the user.</param> | ||
| 25 | public void AppendIfSpecified(string switchName, int value) | ||
| 26 | { | ||
| 27 | if (value != Unspecified) | ||
| 28 | { | ||
| 29 | this.AppendSwitchIfNotNull(switchName, value.ToString(CultureInfo.InvariantCulture)); | ||
| 30 | } | ||
| 31 | } | ||
| 32 | |||
| 33 | /// <summary> | ||
| 34 | /// Append a switch to the command line if the condition is true. | ||
| 35 | /// </summary> | ||
| 36 | /// <param name="switchName">Switch to append.</param> | ||
| 37 | /// <param name="condition">Condition specified by the user.</param> | ||
| 38 | public void AppendIfTrue(string switchName, bool condition) | ||
| 39 | { | ||
| 40 | if (condition) | ||
| 41 | { | ||
| 42 | this.AppendSwitch(switchName); | ||
| 43 | } | ||
| 44 | } | ||
| 45 | |||
| 46 | /// <summary> | ||
| 47 | /// Append a switch to the command line if any values in the array have been specified. | ||
| 48 | /// </summary> | ||
| 49 | /// <param name="switchName">Switch to append.</param> | ||
| 50 | /// <param name="values">Values specified by the user.</param> | ||
| 51 | public void AppendArrayIfNotNull(string switchName, IEnumerable<ITaskItem> values) | ||
| 52 | { | ||
| 53 | if (values != null) | ||
| 54 | { | ||
| 55 | foreach (ITaskItem value in values) | ||
| 56 | { | ||
| 57 | this.AppendSwitchIfNotNull(switchName, value); | ||
| 58 | } | ||
| 59 | } | ||
| 60 | } | ||
| 61 | |||
| 62 | /// <summary> | ||
| 63 | /// Append a switch to the command line if any values in the array have been specified. | ||
| 64 | /// </summary> | ||
| 65 | /// <param name="switchName">Switch to append.</param> | ||
| 66 | /// <param name="values">Values specified by the user.</param> | ||
| 67 | public void AppendArrayIfNotNull(string switchName, IEnumerable<string> values) | ||
| 68 | { | ||
| 69 | if (values != null) | ||
| 70 | { | ||
| 71 | foreach (string value in values) | ||
| 72 | { | ||
| 73 | this.AppendSwitchIfNotNull(switchName, value); | ||
| 74 | } | ||
| 75 | } | ||
| 76 | } | ||
| 77 | |||
| 78 | /// <summary> | ||
| 79 | /// Append arbitrary text to the command-line if specified. | ||
| 80 | /// </summary> | ||
| 81 | /// <param name="textToAppend">Text to append.</param> | ||
| 82 | public void AppendTextIfNotNull(string textToAppend) | ||
| 83 | { | ||
| 84 | if (!String.IsNullOrEmpty(textToAppend)) | ||
| 85 | { | ||
| 86 | this.AppendSpaceIfNotEmpty(); | ||
| 87 | this.AppendTextUnquoted(textToAppend); | ||
| 88 | } | ||
| 89 | } | ||
| 90 | |||
| 91 | /// <summary> | ||
| 92 | /// Append arbitrary text to the command-line if specified. | ||
| 93 | /// </summary> | ||
| 94 | /// <param name="textToAppend">Text to append.</param> | ||
| 95 | public void AppendTextIfNotWhitespace(string textToAppend) | ||
| 96 | { | ||
| 97 | if (!String.IsNullOrWhiteSpace(textToAppend)) | ||
| 98 | { | ||
| 99 | this.AppendSpaceIfNotEmpty(); | ||
| 100 | this.AppendTextUnquoted(textToAppend); | ||
| 101 | } | ||
| 102 | } | ||
| 103 | } | ||
| 104 | } | ||
diff --git a/src/internal/WixToolset.BaseBuildTasks.Sources/WixToolset.BaseBuildTasks.Sources.csproj b/src/internal/WixToolset.BaseBuildTasks.Sources/WixToolset.BaseBuildTasks.Sources.csproj deleted file mode 100644 index 6ae5165e..00000000 --- a/src/internal/WixToolset.BaseBuildTasks.Sources/WixToolset.BaseBuildTasks.Sources.csproj +++ /dev/null | |||
| @@ -1,36 +0,0 @@ | |||
| 1 | <?xml version="1.0" encoding="utf-8"?> | ||
| 2 | <!-- 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. --> | ||
| 3 | |||
| 4 | <Project> | ||
| 5 | <Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" /> | ||
| 6 | |||
| 7 | <PropertyGroup> | ||
| 8 | <TargetFramework>netstandard2.0</TargetFramework> | ||
| 9 | <PackageDescription>WiX Toolset BuildTasks Foundation Sources</PackageDescription> | ||
| 10 | <IsPackable>true</IsPackable> | ||
| 11 | <EnableDefaultItems>false</EnableDefaultItems> | ||
| 12 | <IncludeBuildOutput>false</IncludeBuildOutput> | ||
| 13 | <ContentTargetFolders>contentFiles</ContentTargetFolders> | ||
| 14 | <DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences> | ||
| 15 | <GenerateAssemblyInfo>false</GenerateAssemblyInfo> | ||
| 16 | <GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute> | ||
| 17 | <NoWarn>CS8021</NoWarn> | ||
| 18 | <NoBuild>true</NoBuild> | ||
| 19 | <GeneratePackageOnBuild>true</GeneratePackageOnBuild> | ||
| 20 | <SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking> | ||
| 21 | </PropertyGroup> | ||
| 22 | |||
| 23 | <ItemGroup> | ||
| 24 | <Compile Include="*.cs" Pack="true" PackagePath="$(ContentTargetFolders)\cs\netstandard2.0\$(PackageId)\%(RecursiveDir)" /> | ||
| 25 | <EmbeddedResource Include="*.resx" Pack="true" PackagePath="$(ContentTargetFolders)\any\any\$(PackageId)\%(RecursiveDir)" /> | ||
| 26 | </ItemGroup> | ||
| 27 | |||
| 28 | <ItemGroup> | ||
| 29 | <PackageReference Remove="@(PackageReference)" /> | ||
| 30 | </ItemGroup> | ||
| 31 | |||
| 32 | <Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" /> | ||
| 33 | |||
| 34 | <Target Name="Compile" /> | ||
| 35 | <Target Name="CopyFilesToOutputDirectory" /> | ||
| 36 | </Project> | ||
