@joebigelow / wix / commits / 07b3d459

Normalize ToolsetTask implementation to call wix.exe and heat.exe

Share the ToolsetTask implementation that can find .NET Core and .NET Framework with multiple architectures. Fixes 6951

Rob Mensching committed Oct 12, 2022 at 22:01 UTC 07b3d459ea0a45cbef29b98d283edafbab26462a
31 files changed +197 -201
devbuild.cmd
+1 -1
@@ -12,7 +12,7 @@ if not "%1"=="" shift & goto parse_args
12 if not "%_INCREMENTAL%"=="1" call src\clean.cmd
13 if not "%_CLEAN%"=="" goto end
14
15 -src\build_all.cmd %_C%
15 +call src\build_all.cmd %_C%
16
17 :end
18 popd
src/internal/SetBuildNumber/Directory.Packages.props.pp
+1
@@ -8,6 +8,7 @@
8
9 <PackageVersion Include="WixBuildTools.TestSupport" Version="{packageversion}" />
10 <PackageVersion Include="WixBuildTools.TestSupport.Native" Version="{packageversion}" />
11 + <PackageVersion Include="WixToolset.BaseBuildTasks.Sources" Version="{packageversion}" />
12
13 <PackageVersion Include="WixToolset.DUtil" Version="{packageversion}" />
14 <PackageVersion Include="WixToolset.WcaUtil" Version="{packageversion}" />
src/internal/WixToolset.BaseBuildTasks.Sources/BaseToolsetTask.cs renamed
+5 -4
@@ -1,13 +1,13 @@
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.BuildTasks
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 ToolsetTask : ToolTask
10 + public abstract class BaseToolsetTask : ToolTask
11 {
12 /// <summary>
13 /// Gets or sets additional options that are appended the the tool command-line.
@@ -88,6 +88,7 @@ namespace WixToolset.BuildTasks
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()
@@ -152,11 +153,11 @@ namespace WixToolset.BuildTasks
153 private string GetDefaultToolFullPath()
154 {
155 #if NETCOREAPP
155 - var thisTaskFolder = Path.GetDirectoryName(typeof(ToolsetTask).Assembly.Location);
156 + var thisTaskFolder = Path.GetDirectoryName(typeof(BaseToolsetTask).Assembly.Location);
157
158 return Path.Combine(thisTaskFolder, this.ToolExe);
159 #else
159 - var thisTaskFolder = Path.GetDirectoryName(new Uri(typeof(ToolsetTask).Assembly.CodeBase).AbsolutePath);
160 + var thisTaskFolder = Path.GetDirectoryName(new Uri(typeof(BaseToolsetTask).Assembly.CodeBase).AbsolutePath);
161
162 var archFolder = GetArchitectureFolder(thisTaskFolder);
163
src/internal/WixToolset.BaseBuildTasks.Sources/FileSearchHelperMethods.cs renamed
+1 -1
@@ -1,6 +1,6 @@
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.BuildTasks
3 +namespace WixToolset.BaseBuildTasks
4 {
5 using System;
6 using System.IO;
src/internal/WixToolset.BaseBuildTasks.Sources/WixCommandLineBuilder.cs renamed
+1 -1
@@ -1,6 +1,6 @@
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.BuildTasks
3 +namespace WixToolset.BaseBuildTasks
4 {
5 using System;
6 using System.Collections.Generic;
src/internal/WixToolset.BaseBuildTasks.Sources/WixToolset.BaseBuildTasks.Sources.csproj new
+36
@@ -0,0 +1,36 @@
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>
src/internal/internal.cmd
+2
@@ -33,8 +33,10 @@ msbuild internal_t.proj -p:Configuration=%_C% -nologo -warnaserror -bl:%_L%\inte
33 @rd /s/q "..\..\build\internal" 2> nul
34 @del "..\..\build\artifacts\WixBuildTools.TestSupport.*.nupkg" 2> nul
35 @del "..\..\build\artifacts\WixBuildTools.TestSupport.Native.*.nupkg" 2> nul
36 +@del "..\..\build\artifacts\WixToolset.BaseBuildTasks.Sources.*.nupkg" 2> nul
37 @rd /s/q "%USERPROFILE%\.nuget\packages\wixbuildtools.testsupport" 2> nul
38 @rd /s/q "%USERPROFILE%\.nuget\packages\wixbuildtools.testsupport.native" 2> nul
39 +@rd /s/q "%USERPROFILE%\.nuget\packages\wixtoolset.basebuildtasks.sources" 2> nul
40 @exit /b
41
42 :end
src/internal/internal.sln
+20 -2
@@ -1,12 +1,14 @@
1 
2 Microsoft Visual Studio Solution File, Format Version 12.00
3 -# Visual Studio Version 16
4 -VisualStudioVersion = 16.6.30114.105
3 +# Visual Studio Version 17
4 +VisualStudioVersion = 17.3.32929.385
5 MinimumVisualStudioVersion = 10.0.40219.1
6 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixBuildTools.TestSupport", "WixBuildTools.TestSupport\WixBuildTools.TestSupport.csproj", "{8E082709-7355-41D5-AF86-6BBF9C89BDD7}"
7 EndProject
8 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WixBuildTools.TestSupport.Native", "WixBuildTools.TestSupport.Native\WixBuildTools.TestSupport.Native.vcxproj", "{95BABD97-FBDB-453A-AF8A-FA031A07B599}"
9 EndProject
10 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolset.BaseBuildTasks.Sources", "WixToolset.BaseBuildTasks.Sources\WixToolset.BaseBuildTasks.Sources.csproj", "{6B654490-AB0D-4F94-B564-DAA80044D5A3}"
11 +EndProject
12 Global
13 GlobalSection(SolutionConfigurationPlatforms) = preSolution
14 Debug|Any CPU = Debug|Any CPU
@@ -47,6 +49,22 @@ Global
49 {95BABD97-FBDB-453A-AF8A-FA031A07B599}.Release|x64.ActiveCfg = Release|Win32
50 {95BABD97-FBDB-453A-AF8A-FA031A07B599}.Release|x86.ActiveCfg = Release|Win32
51 {95BABD97-FBDB-453A-AF8A-FA031A07B599}.Release|x86.Build.0 = Release|Win32
52 + {6B654490-AB0D-4F94-B564-DAA80044D5A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
53 + {6B654490-AB0D-4F94-B564-DAA80044D5A3}.Debug|Any CPU.Build.0 = Debug|Any CPU
54 + {6B654490-AB0D-4F94-B564-DAA80044D5A3}.Debug|ARM64.ActiveCfg = Debug|Any CPU
55 + {6B654490-AB0D-4F94-B564-DAA80044D5A3}.Debug|ARM64.Build.0 = Debug|Any CPU
56 + {6B654490-AB0D-4F94-B564-DAA80044D5A3}.Debug|x64.ActiveCfg = Debug|Any CPU
57 + {6B654490-AB0D-4F94-B564-DAA80044D5A3}.Debug|x64.Build.0 = Debug|Any CPU
58 + {6B654490-AB0D-4F94-B564-DAA80044D5A3}.Debug|x86.ActiveCfg = Debug|Any CPU
59 + {6B654490-AB0D-4F94-B564-DAA80044D5A3}.Debug|x86.Build.0 = Debug|Any CPU
60 + {6B654490-AB0D-4F94-B564-DAA80044D5A3}.Release|Any CPU.ActiveCfg = Release|Any CPU
61 + {6B654490-AB0D-4F94-B564-DAA80044D5A3}.Release|Any CPU.Build.0 = Release|Any CPU
62 + {6B654490-AB0D-4F94-B564-DAA80044D5A3}.Release|ARM64.ActiveCfg = Release|Any CPU
63 + {6B654490-AB0D-4F94-B564-DAA80044D5A3}.Release|ARM64.Build.0 = Release|Any CPU
64 + {6B654490-AB0D-4F94-B564-DAA80044D5A3}.Release|x64.ActiveCfg = Release|Any CPU
65 + {6B654490-AB0D-4F94-B564-DAA80044D5A3}.Release|x64.Build.0 = Release|Any CPU
66 + {6B654490-AB0D-4F94-B564-DAA80044D5A3}.Release|x86.ActiveCfg = Release|Any CPU
67 + {6B654490-AB0D-4F94-B564-DAA80044D5A3}.Release|x86.Build.0 = Release|Any CPU
68 EndGlobalSection
69 GlobalSection(SolutionProperties) = preSolution
70 HideSolutionNode = FALSE
src/internal/internal_t.proj
+1
@@ -1,5 +1,6 @@
1 <Project Sdk="Microsoft.Build.Traversal">
2 <ItemGroup>
3 + <ProjectReference Include="WixToolset.BaseBuildTasks.Sources\WixToolset.BaseBuildTasks.Sources.csproj" Targets="Pack" />
4 <ProjectReference Include="WixBuildTools.TestSupport\WixBuildTools.TestSupport.csproj" Targets="Pack" />
5 <ProjectReference Include="WixBuildTools.TestSupport.Native\WixBuildTools.TestSupport.Native.vcxproj" Properties="Platform=x86" />
6 <ProjectReference Include="WixBuildTools.TestSupport.Native\WixBuildTools.TestSupport.Native.vcxproj" Properties="Platform=x64" />
src/test/wix/TestData/WixprojPackageHarvesting/Package.wxs new
+12
@@ -0,0 +1,12 @@
1 +<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
2 + <Package Name='WixprojPackageHarvesting' Manufacturer='WiX Toolset' Version='0.0.1' UpgradeCode='41a2c17e-1976-465b-bcde-eae03516ca68'>
3 +
4 + <StandardDirectory Id='ProgramFiles6432Folder'>
5 + <Directory Id='ApplicationFolder' Name='Test App' />
6 + </StandardDirectory>
7 +
8 + <Feature Id='Main'>
9 + <ComponentGroupRef Id='HarvestedComponents' />
10 + </Feature>
11 + </Package>
12 +</Wix>
src/test/wix/TestData/WixprojPackageHarvesting/WixprojPackageHarvesting.wixproj new
+21
@@ -0,0 +1,21 @@
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 +<Project Sdk='WixToolset.Sdk'>
4 + <PropertyGroup>
5 + <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
6 + <SuppressValidation>true</SuppressValidation>
7 + </PropertyGroup>
8 +
9 + <ItemGroup>
10 + <HarvestDirectory Include="_data">
11 + <ComponentGroupName>HarvestedComponents</ComponentGroupName>
12 + <DirectoryRefId>ApplicationFolder</DirectoryRefId>
13 + <SuppressRootDirectory>true</SuppressRootDirectory>
14 + </HarvestDirectory>
15 + <BindInputPaths Include="_data" />
16 + </ItemGroup>
17 +
18 + <ItemGroup>
19 + <PackageReference Include="Wixtoolset.Heat" />
20 + </ItemGroup>
21 +</Project>
src/test/wix/TestData/WixprojPackageHarvesting/_data/a.txt new
+1
@@ -0,0 +1 @@
1 +This is a.txt.
src/test/wix/TestData/WixprojPackageHarvesting/_data/b.txt new
+1
@@ -0,0 +1 @@
1 +This is b.txt.
src/test/wix/TestData/WixprojPackageHeatDir/Package.wxs new
+12
@@ -0,0 +1,12 @@
1 +<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
2 + <Package Name='WixprojPackageHarvesting' Manufacturer='WiX Toolset' Version='0.0.1' UpgradeCode='41a2c17e-1976-465b-bcde-eae03516ca68'>
3 +
4 + <StandardDirectory Id='ProgramFiles6432Folder'>
5 + <Directory Id='ApplicationFolder' Name='Test App' />
6 + </StandardDirectory>
7 +
8 + <Feature Id='Main'>
9 + <ComponentGroupRef Id='HarvestedComponents' />
10 + </Feature>
11 + </Package>
12 +</Wix>
src/test/wix/TestData/WixprojPackageHeatDir/WixprojPackageHeatDir.wixproj new
+30
@@ -0,0 +1,30 @@
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 +<Project Sdk='WixToolset.Sdk'>
4 + <PropertyGroup>
5 + <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
6 + <SuppressValidation>true</SuppressValidation>
7 + </PropertyGroup>
8 +
9 + <ItemGroup>
10 + <BindInputPaths Include="_data" />
11 + </ItemGroup>
12 +
13 + <ItemGroup>
14 + <PackageReference Include="Wixtoolset.Heat" />
15 + </ItemGroup>
16 +
17 + <Target Name="ManualHarvest" BeforeTargets="BeforeBuild">
18 + <HeatDirectory
19 + Directory="_data"
20 + AutogenerateGuids="true"
21 + ComponentGroupName="HarvestedComponents"
22 + DirectoryRefId="ApplicationFolder"
23 + OutputFile="obj\_g.wxs"
24 + />
25 + <ItemGroup>
26 + <Compile Include="obj\_g.wxs" />
27 + </ItemGroup>
28 + </Target>
29 +
30 +</Project>
src/test/wix/TestData/WixprojPackageHeatDir/_data/a.txt new
+1
@@ -0,0 +1 @@
1 +This is a.txt.
src/test/wix/TestData/WixprojPackageHeatDir/_data/b.txt new
+1
@@ -0,0 +1 @@
1 +This is b.txt.
src/test/wix/WixE2E/WixE2EFixture.cs
+31
@@ -115,6 +115,32 @@ namespace WixE2E
115 Assert.NotEqual(firstHashes, secondHashes);
116 }
117
118 + [Theory]
119 + [InlineData(false)]
120 + [InlineData(true)]
121 + public void CanBuildPackageWithHarvesting(bool x64)
122 + {
123 + var projectPath = TestData.Get("TestData", "WixprojPackageHarvesting", "WixprojPackageHarvesting.wixproj");
124 +
125 + CleanEverything();
126 +
127 + var result = RestoreAndBuild(projectPath, x64);
128 + result.AssertSuccess();
129 + }
130 +
131 + [Theory]
132 + [InlineData(false)]
133 + [InlineData(true)]
134 + public void CanBuildPackageWithHeatDir(bool x64)
135 + {
136 + var projectPath = TestData.Get("TestData", "WixprojPackageHeatDir", "WixprojPackageHeatDir.wixproj");
137 +
138 + CleanEverything();
139 +
140 + var result = RestoreAndBuild(projectPath, x64);
141 + result.AssertSuccess();
142 + }
143 +
144 [Fact(Skip = "Investigate if .NET Core WebApplications can be incrementally built")]
145 public void CanIncrementalBuildPackageWithNetCoreWebAppWithoutEdits()
146 {
@@ -161,6 +187,11 @@ namespace WixE2E
187 }
188 }
189 }
190 +
191 + foreach (var logFile in Directory.GetFiles(rootFolder, "*.binlog", SearchOption.AllDirectories))
192 + {
193 + File.Delete(logFile);
194 + }
195 }
196
197 private static string GetFileHash(string path)
src/tools/WixToolset.HeatTasks/HeatDirectory.cs
+1
@@ -3,6 +3,7 @@
3 namespace WixToolset.HeatTasks
4 {
5 using Microsoft.Build.Framework;
6 + using WixToolset.BaseBuildTasks;
7
8 public sealed class HeatDirectory : HeatTask
9 {
src/tools/WixToolset.HeatTasks/HeatFile.cs
+1
@@ -3,6 +3,7 @@
3 namespace WixToolset.HeatTasks
4 {
5 using Microsoft.Build.Framework;
6 + using WixToolset.BaseBuildTasks;
7
8 public sealed class HeatFile : HeatTask
9 {
src/tools/WixToolset.HeatTasks/HeatProject.cs
+1
@@ -3,6 +3,7 @@
3 namespace WixToolset.HeatTasks
4 {
5 using Microsoft.Build.Framework;
6 + using WixToolset.BaseBuildTasks;
7
8 public sealed class HeatProject : HeatTask
9 {
src/tools/WixToolset.HeatTasks/HeatTask.cs
+5 -134
@@ -2,64 +2,15 @@
2
3 namespace WixToolset.HeatTasks
4 {
5 - using System;
6 - using System.IO;
7 - using System.Runtime.InteropServices;
5 using Microsoft.Build.Framework;
9 - using Microsoft.Build.Utilities;
6 + using WixToolset.BaseBuildTasks;
7
8 /// <summary>
9 /// A base MSBuild task to run the WiX harvester.
10 /// Specific harvester tasks should extend this class.
11 /// </summary>
15 - public abstract partial class HeatTask : ToolTask
12 + public abstract partial class HeatTask : BaseToolsetTask
13 {
17 -#if NETFRAMEWORK
18 - private static readonly string ThisDllPath = new Uri(typeof(HeatTask).Assembly.CodeBase).AbsolutePath;
19 -#else
20 - private static readonly string ThisDllPath = typeof(HeatTask).Assembly.Location;
21 -#endif
22 -
23 -
24 - /// <summary>
25 - /// Gets or sets additional options that are appended the the tool command-line.
26 - /// </summary>
27 - /// <remarks>
28 - /// This allows the task to support extended options in the tool which are not
29 - /// explicitly implemented as properties on the task.
30 - /// </remarks>
31 - public string AdditionalOptions { get; set; }
32 -
33 - /// <summary>
34 - /// Gets or sets whether to display the logo.
35 - /// </summary>
36 - public bool NoLogo { get; set; }
37 -
38 - /// <summary>
39 - /// Gets or sets whether all warnings should be suppressed.
40 - /// </summary>
41 - public bool SuppressAllWarnings { get; set; }
42 -
43 - /// <summary>
44 - /// Gets or sets a list of specific warnings to be suppressed.
45 - /// </summary>
46 - public string[] SuppressSpecificWarnings { get; set; }
47 -
48 - /// <summary>
49 - /// Gets or sets whether all warnings should be treated as errors.
50 - /// </summary>
51 - public bool TreatWarningsAsErrors { get; set; }
52 -
53 - /// <summary>
54 - /// Gets or sets a list of specific warnings to treat as errors.
55 - /// </summary>
56 - public string[] TreatSpecificWarningsAsErrors { get; set; }
57 -
58 - /// <summary>
59 - /// Gets or sets whether to display verbose output.
60 - /// </summary>
61 - public bool VerboseOutput { get; set; }
62 -
14 public bool AutogenerateGuids { get; set; }
15
16 public bool GenerateGuidsNow { get; set; }
@@ -74,8 +25,6 @@ namespace WixToolset.HeatTasks
25
26 public string[] Transforms { get; set; }
27
77 - protected sealed override string ToolName => "heat.exe";
78 -
28 /// <summary>
29 /// Gets the name of the heat operation performed by the task.
30 /// </summary>
@@ -83,99 +32,21 @@ namespace WixToolset.HeatTasks
32 /// <value>The name of the heat operation performed by the task.</value>
33 protected abstract string OperationName { get; }
34
86 - private string ToolFullPath
87 - {
88 - get
89 - {
90 - if (String.IsNullOrEmpty(this.ToolPath))
91 - {
92 - return Path.Combine(Path.GetDirectoryName(ThisDllPath), this.ToolExe);
93 - }
94 -
95 - return Path.Combine(this.ToolPath, this.ToolExe);
96 - }
97 - }
98 -
99 - /// <summary>
100 - /// Get the path to the executable.
101 - /// </summary>
102 - /// <remarks>
103 - /// ToolTask only calls GenerateFullPathToTool when the ToolPath property is not set.
104 - /// WiX never sets the ToolPath property, but the user can through $(HeatToolDir).
105 - /// If we return only a file name, ToolTask will search the system paths for it.
106 - /// </remarks>
107 - protected sealed override string GenerateFullPathToTool()
108 - {
109 -#if NETCOREAPP
110 - // If we're not using heat.exe, use dotnet.exe to exec heat.dll.
111 - // See this.GenerateCommandLine() where "exec heat.dll" is added.
112 - if (!IsSelfExecutable(this.ToolFullPath, out var toolFullPath))
113 - {
114 - return DotnetFullPath;
115 - }
116 -
117 - return toolFullPath;
118 -#else
119 - return this.ToolFullPath;
120 -#endif
121 - }
122 -
123 - protected sealed override string GenerateCommandLineCommands()
124 - {
125 - var commandLineBuilder = new WixCommandLineBuilder();
126 -
127 -#if NETCOREAPP
128 - // If we're using dotnet.exe as the target executable, see this.GenerateFullPathToTool(),
129 - // then add "exec heat.dll" to the beginning of the command-line.
130 - if (!IsSelfExecutable(this.ToolFullPath, out var toolFullPath))
131 - {
132 - //commandLineBuilder.AppendSwitchIfNotNull("exec ", toolFullPath);
133 - commandLineBuilder.AppendSwitch($"exec \"{toolFullPath}\"");
134 - }
135 -#endif
136 -
137 - this.BuildCommandLine(commandLineBuilder);
138 - return commandLineBuilder.ToString();
139 - }
35 + protected sealed override string ToolName => "heat.exe";
36
37 /// <summary>
38 /// Builds a command line from options in this task.
39 /// </summary>
144 - protected virtual void BuildCommandLine(WixCommandLineBuilder commandLineBuilder)
40 + protected override void BuildCommandLine(WixCommandLineBuilder commandLineBuilder)
41 {
146 - commandLineBuilder.AppendIfTrue("-nologo", this.NoLogo);
147 - commandLineBuilder.AppendArrayIfNotNull("-sw", this.SuppressSpecificWarnings);
148 - commandLineBuilder.AppendIfTrue("-sw", this.SuppressAllWarnings);
149 - commandLineBuilder.AppendIfTrue("-v", this.VerboseOutput);
150 - commandLineBuilder.AppendArrayIfNotNull("-wx", this.TreatSpecificWarningsAsErrors);
151 - commandLineBuilder.AppendIfTrue("-wx", this.TreatWarningsAsErrors);
42 + base.BuildCommandLine(commandLineBuilder);
43
44 commandLineBuilder.AppendIfTrue("-ag", this.AutogenerateGuids);
45 commandLineBuilder.AppendIfTrue("-gg", this.GenerateGuidsNow);
46 commandLineBuilder.AppendIfTrue("-sfrag", this.SuppressFragments);
47 commandLineBuilder.AppendIfTrue("-suid", this.SuppressUniqueIds);
48 commandLineBuilder.AppendArrayIfNotNull("-t ", this.Transforms);
158 - commandLineBuilder.AppendTextIfNotNull(this.AdditionalOptions);
49 commandLineBuilder.AppendSwitchIfNotNull("-out ", this.OutputFile);
50 }
161 -
162 -#if NETCOREAPP
163 - private static readonly string DotnetFullPath = Environment.GetEnvironmentVariable("DOTNET_HOST_PATH") ?? "dotnet";
164 -
165 - private static bool IsSelfExecutable(string proposedToolFullPath, out string toolFullPath)
166 - {
167 - var toolFullPathWithoutExtension = Path.Combine(Path.GetDirectoryName(proposedToolFullPath), Path.GetFileNameWithoutExtension(proposedToolFullPath));
168 - var exeExtension = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ".exe" : String.Empty;
169 - var exeToolFullPath = $"{toolFullPathWithoutExtension}{exeExtension}";
170 - if (File.Exists(exeToolFullPath))
171 - {
172 - toolFullPath = exeToolFullPath;
173 - return true;
174 - }
175 -
176 - toolFullPath = $"{toolFullPathWithoutExtension}.dll";
177 - return false;
178 - }
179 -#endif
51 }
52 }
src/tools/WixToolset.HeatTasks/WixCommandLineBuilder.cs deleted
-56
@@ -1,56 +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.HeatTasks
4 -{
5 - using System;
6 - using System.Collections.Generic;
7 - using Microsoft.Build.Utilities;
8 -
9 - /// <summary>
10 - /// Helper class for appending the command line arguments.
11 - /// </summary>
12 - public class WixCommandLineBuilder : CommandLineBuilder
13 - {
14 - /// <summary>
15 - /// Append a switch to the command line if the condition is true.
16 - /// </summary>
17 - /// <param name="switchName">Switch to append.</param>
18 - /// <param name="condition">Condition specified by the user.</param>
19 - public void AppendIfTrue(string switchName, bool condition)
20 - {
21 - if (condition)
22 - {
23 - this.AppendSwitch(switchName);
24 - }
25 - }
26 -
27 - /// <summary>
28 - /// Append a switch to the command line if any values in the array have been specified.
29 - /// </summary>
30 - /// <param name="switchName">Switch to append.</param>
31 - /// <param name="values">Values specified by the user.</param>
32 - public void AppendArrayIfNotNull(string switchName, IEnumerable<string> values)
33 - {
34 - if (values != null)
35 - {
36 - foreach (var value in values)
37 - {
38 - this.AppendSwitchIfNotNull(switchName, value);
39 - }
40 - }
41 - }
42 -
43 - /// <summary>
44 - /// Append arbitrary text to the command-line if specified.
45 - /// </summary>
46 - /// <param name="textToAppend">Text to append.</param>
47 - public void AppendTextIfNotNull(string textToAppend)
48 - {
49 - if (!String.IsNullOrWhiteSpace(textToAppend))
50 - {
51 - this.AppendSpaceIfNotEmpty();
52 - this.AppendTextUnquoted(textToAppend);
53 - }
54 - }
55 - }
56 -}
src/tools/WixToolset.HeatTasks/WixToolset.HeatTasks.csproj
+1
@@ -12,5 +12,6 @@
12
13 <ItemGroup>
14 <PackageReference Include="Microsoft.Build.Tasks.Core" />
15 + <PackageReference Include="WixToolset.BaseBuildTasks.Sources" />
16 </ItemGroup>
17 </Project>
src/wix/WixToolset.BuildTasks/DetachBundleEngineForSigning.cs
+1
@@ -3,6 +3,7 @@
3 namespace WixToolset.BuildTasks
4 {
5 using Microsoft.Build.Framework;
6 + using WixToolset.BaseBuildTasks;
7
8 /// <summary>
9 /// An MSBuild task to run WiX to detach bundle engine to be signed.
src/wix/WixToolset.BuildTasks/InscribeMsiWithCabinetSignatures.cs
+1
@@ -3,6 +3,7 @@
3 namespace WixToolset.BuildTasks
4 {
5 using Microsoft.Build.Framework;
6 + using WixToolset.BaseBuildTasks;
7
8 /// <summary>
9 /// An MSBuild task to run WiX to update cabinet signatures in a MSI.
src/wix/WixToolset.BuildTasks/ReattachSignedBundleEngine.cs
+1
@@ -3,6 +3,7 @@
3 namespace WixToolset.BuildTasks
4 {
5 using Microsoft.Build.Framework;
6 + using WixToolset.BaseBuildTasks;
7
8 /// <summary>
9 /// An MSBuild task to run WiX to reattach a (signed) bundle engine to its bundle.
src/wix/WixToolset.BuildTasks/WindowsInstallerValidation.cs
+1
@@ -3,6 +3,7 @@
3 namespace WixToolset.BuildTasks
4 {
5 using Microsoft.Build.Framework;
6 + using WixToolset.BaseBuildTasks;
7
8 /// <summary>
9 /// An MSBuild task to run WiX to detach bundle engine to be signed.
src/wix/WixToolset.BuildTasks/WixBuild.cs
+1
@@ -5,6 +5,7 @@ namespace WixToolset.BuildTasks
5 using System;
6 using System.Collections.Generic;
7 using Microsoft.Build.Framework;
8 + using WixToolset.BaseBuildTasks;
9
10 /// <summary>
11 /// An MSBuild task to run the WiX compiler.
src/wix/WixToolset.BuildTasks/WixExeBaseTask.cs
+3 -1
@@ -2,10 +2,12 @@
2
3 namespace WixToolset.BuildTasks
4 {
5 + using WixToolset.BaseBuildTasks;
6 +
7 /// <summary>
8 /// An MSBuild task to run WiX to update cabinet signatures in a MSI.
9 /// </summary>
8 - public abstract class WixExeBaseTask : ToolsetTask
10 + public abstract class WixExeBaseTask : BaseToolsetTask
11 {
12 protected override string ToolName => "wix.exe";
13 }
src/wix/WixToolset.BuildTasks/WixToolset.BuildTasks.csproj
+2 -1
@@ -12,7 +12,8 @@
12 </PropertyGroup>
13
14 <ItemGroup>
15 - <PackageReference Include="WixToolset.Dtf.WindowsInstaller" />
15 <PackageReference Include="Microsoft.Build.Tasks.Core" />
16 + <PackageReference Include="WixToolset.BaseBuildTasks.Sources" />
17 + <PackageReference Include="WixToolset.Dtf.WindowsInstaller" />
18 </ItemGroup>
19 </Project>