@joebigelow / wix / commits / e087bb76

Implement Heat tasks from WixToolset.Harvesters

Sean Hall committed May 8, 2020 at 21:57 UTC e087bb766a7f85d78d1bfa7b240a08db4e27f730
17 files changed +303 -148
nuget.config
+1
@@ -9,6 +9,7 @@
9 <add key="wixtoolset-dtf" value="https://ci.appveyor.com/nuget/wixtoolset-dtf" />
10 <add key="wixtoolset-dutil" value="https://ci.appveyor.com/nuget/wixtoolset-dutil" />
11 <add key="wixtoolset-extensibility" value="https://ci.appveyor.com/nuget/wixtoolset-extensibility" />
12 + <add key="wixtoolset-harvesters" value="https://ci.appveyor.com/nuget/wixtoolset-harvesters" />
13 <add key="wixbuildtools" value="https://ci.appveyor.com/nuget/wixbuildtools" />
14 <add key="api.nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
15 </packageSources>
src/WixToolset.BuildTasks/DoIt.cs
+6 -67
@@ -16,10 +16,8 @@ namespace WixToolset.BuildTasks
16 /// <summary>
17 /// An MSBuild task to run the WiX compiler.
18 /// </summary>
19 - public sealed class DoIt : Task
19 + public sealed class DoIt : ToolsetTask
20 {
21 - public string AdditionalOptions { get; set; }
22 -
21 public string[] Cultures { get; set; }
22
23 public string[] DefineConstants { get; set; }
@@ -37,8 +35,6 @@ namespace WixToolset.BuildTasks
35
36 public ITaskItem[] LocalizationFiles { get; set; }
37
40 - public bool NoLogo { get; set; }
41 -
38 public ITaskItem[] LibraryFiles { get; set; }
39
40 [Output]
@@ -59,32 +55,6 @@ namespace WixToolset.BuildTasks
55 public string[] ReferencePaths { get; set; }
56
57
62 - /// <summary>
63 - /// Gets or sets whether all warnings should be suppressed.
64 - /// </summary>
65 - public bool SuppressAllWarnings { get; set; }
66 -
67 - /// <summary>
68 - /// Gets or sets a list of specific warnings to be suppressed.
69 - /// </summary>
70 - public string[] SuppressSpecificWarnings { get; set; }
71 -
72 - /// <summary>
73 - /// Gets or sets whether all warnings should be treated as errors.
74 - /// </summary>
75 - public bool TreatWarningsAsErrors { get; set; }
76 -
77 - /// <summary>
78 - /// Gets or sets a list of specific warnings to treat as errors.
79 - /// </summary>
80 - public string[] TreatSpecificWarningsAsErrors { get; set; }
81 -
82 - /// <summary>
83 - /// Gets or sets whether to display verbose output.
84 - /// </summary>
85 - public bool VerboseOutput { get; set; }
86 -
87 -
58 public ITaskItem[] BindInputPaths { get; set; }
59
60 public bool BindFiles { get; set; }
@@ -109,37 +79,10 @@ namespace WixToolset.BuildTasks
79 public string[] SuppressIces { get; set; }
80 public string AdditionalCub { get; set; }
81
112 - public override bool Execute()
113 - {
114 - var serviceProvider = WixToolsetServiceProviderFactory.CreateServiceProvider();
115 -
116 - var listener = new MsbuildMessageListener(this.Log, "WIX", this.BuildEngine.ProjectFileOfTaskNode);
117 -
118 - try
119 - {
120 - this.ExecuteCore(serviceProvider, listener);
121 - }
122 - catch (WixException e)
123 - {
124 - listener.Write(e.Error);
125 - }
126 - catch (Exception e)
127 - {
128 - this.Log.LogErrorFromException(e, showStackTrace: true, showDetail: true, null);
129 -
130 - if (e is NullReferenceException || e is SEHException)
131 - {
132 - throw;
133 - }
134 - }
82 + protected override string TaskShortName => "WIX";
83
136 - return !this.Log.HasLoggedErrors;
137 - }
138 -
139 - private void ExecuteCore(IWixToolsetServiceProvider serviceProvider, IMessageListener listener)
84 + protected override void ExecuteCore(IWixToolsetServiceProvider serviceProvider, IMessageListener listener, string commandLineString)
85 {
141 - var commandLineString = this.BuildCommandLine();
142 -
86 this.Log.LogMessage(MessageImportance.Normal, "wix.exe " + commandLineString);
87
88 var messaging = serviceProvider.GetService<IMessaging>();
@@ -155,10 +98,8 @@ namespace WixToolset.BuildTasks
98 command?.Execute();
99 }
100
158 - private string BuildCommandLine()
101 + protected override void BuildCommandLine(WixCommandLineBuilder commandLineBuilder)
102 {
160 - var commandLineBuilder = new WixCommandLineBuilder();
161 -
103 commandLineBuilder.AppendTextUnquoted("build");
104
105 commandLineBuilder.AppendSwitchIfNotNull("-platform ", this.InstallerPlatform);
@@ -166,14 +107,12 @@ namespace WixToolset.BuildTasks
107 commandLineBuilder.AppendSwitchIfNotNull("-outputType ", this.OutputType);
108 commandLineBuilder.AppendSwitchIfNotNull("-pdb ", this.PdbFile);
109 commandLineBuilder.AppendSwitchIfNotNull("-pdbType ", this.PdbType);
169 - commandLineBuilder.AppendIfTrue("-nologo", this.NoLogo);
110 commandLineBuilder.AppendArrayIfNotNull("-culture ", this.Cultures);
111 commandLineBuilder.AppendArrayIfNotNull("-d ", this.DefineConstants);
112 commandLineBuilder.AppendArrayIfNotNull("-I ", this.IncludeSearchPaths);
113 commandLineBuilder.AppendExtensions(this.Extensions, this.ExtensionDirectory, this.ReferencePaths);
114 commandLineBuilder.AppendIfTrue("-sval", this.SuppressValidation);
115 commandLineBuilder.AppendArrayIfNotNull("-sice ", this.SuppressIces);
176 - commandLineBuilder.AppendArrayIfNotNull("-sw ", this.SuppressSpecificWarnings);
116 commandLineBuilder.AppendSwitchIfNotNull("-usf ", this.UnreferencedSymbolsFile);
117 commandLineBuilder.AppendSwitchIfNotNull("-cc ", this.CabinetCachePath);
118 commandLineBuilder.AppendSwitchIfNotNull("-intermediatefolder ", this.IntermediateDirectory);
@@ -181,14 +120,14 @@ namespace WixToolset.BuildTasks
120 commandLineBuilder.AppendSwitchIfNotNull("-outputsfile ", this.BindOutputsFile);
121 commandLineBuilder.AppendSwitchIfNotNull("-builtoutputsfile ", this.BindBuiltOutputsFile);
122
123 + base.BuildCommandLine(commandLineBuilder);
124 +
125 commandLineBuilder.AppendIfTrue("-bindFiles", this.BindFiles);
126 commandLineBuilder.AppendArrayIfNotNull("-bindPath ", this.CalculateBindPathStrings());
127 commandLineBuilder.AppendArrayIfNotNull("-loc ", this.LocalizationFiles);
128 commandLineBuilder.AppendArrayIfNotNull("-lib ", this.LibraryFiles);
129 commandLineBuilder.AppendTextIfNotWhitespace(this.AdditionalOptions);
130 commandLineBuilder.AppendFileNamesIfNotNull(this.SourceFiles, " ");
190 -
191 - return commandLineBuilder.ToString();
131 }
132
133 private IExtensionManager CreateExtensionManagerWithStandardBackends(IWixToolsetServiceProvider serviceProvider, IMessaging messaging, string[] extensions)
src/WixToolset.BuildTasks/HeatDirectory.cs
+1 -10
@@ -4,7 +4,6 @@ namespace WixToolset.BuildTasks
4 {
5 using Microsoft.Build.Framework;
6
7 -#if false
7 public sealed class HeatDirectory : HeatTask
8 {
9 private string directory;
@@ -77,14 +76,8 @@ namespace WixToolset.BuildTasks
76 get { return "dir"; }
77 }
78
80 - /// <summary>
81 - /// Generate the command line arguments to write to the response file from the properties.
82 - /// </summary>
83 - /// <returns>Command line string.</returns>
84 - protected override string GenerateResponseFileCommands()
79 + protected override void BuildCommandLine(WixCommandLineBuilder commandLineBuilder)
80 {
86 - WixCommandLineBuilder commandLineBuilder = new WixCommandLineBuilder();
87 -
81 commandLineBuilder.AppendSwitch(this.OperationName);
82 commandLineBuilder.AppendFileNameIfNotNull(this.Directory);
83
@@ -98,8 +91,6 @@ namespace WixToolset.BuildTasks
91 commandLineBuilder.AppendSwitchIfNotNull("-var ", this.PreprocessorVariable);
92
93 base.BuildCommandLine(commandLineBuilder);
101 - return commandLineBuilder.ToString();
94 }
95 }
104 -#endif
96 }
src/WixToolset.BuildTasks/HeatFile.cs
+1 -10
@@ -4,7 +4,6 @@ namespace WixToolset.BuildTasks
4 {
5 using Microsoft.Build.Framework;
6
7 -#if false
7 public sealed class HeatFile : HeatTask
8 {
9 private string file;
@@ -70,14 +69,8 @@ namespace WixToolset.BuildTasks
69 get { return "file"; }
70 }
71
73 - /// <summary>
74 - /// Generate the command line arguments to write to the response file from the properties.
75 - /// </summary>
76 - /// <returns>Command line string.</returns>
77 - protected override string GenerateResponseFileCommands()
72 + protected override void BuildCommandLine(WixCommandLineBuilder commandLineBuilder)
73 {
79 - WixCommandLineBuilder commandLineBuilder = new WixCommandLineBuilder();
80 -
74 commandLineBuilder.AppendSwitch(this.OperationName);
75 commandLineBuilder.AppendFileNameIfNotNull(this.File);
76
@@ -90,8 +83,6 @@ namespace WixToolset.BuildTasks
83 commandLineBuilder.AppendSwitchIfNotNull("-var ", this.PreprocessorVariable);
84
85 base.BuildCommandLine(commandLineBuilder);
93 - return commandLineBuilder.ToString();
86 }
87 }
96 -#endif
88 }
src/WixToolset.BuildTasks/HeatProject.cs
+1 -10
@@ -4,7 +4,6 @@ namespace WixToolset.BuildTasks
4 {
5 using Microsoft.Build.Framework;
6
7 -#if false
7 public sealed class HeatProject : HeatTask
8 {
9 private string configuration;
@@ -83,14 +82,8 @@ namespace WixToolset.BuildTasks
82 get { return "project"; }
83 }
84
86 - /// <summary>
87 - /// Generate the command line arguments to write to the response file from the properties.
88 - /// </summary>
89 - /// <returns>Command line string.</returns>
90 - protected override string GenerateResponseFileCommands()
85 + protected override void BuildCommandLine(WixCommandLineBuilder commandLineBuilder)
86 {
92 - WixCommandLineBuilder commandLineBuilder = new WixCommandLineBuilder();
93 -
87 commandLineBuilder.AppendSwitch(this.OperationName);
88 commandLineBuilder.AppendFileNameIfNotNull(this.Project);
89
@@ -103,8 +96,6 @@ namespace WixToolset.BuildTasks
96 commandLineBuilder.AppendIfTrue("-wixvar", this.GenerateWixVariables);
97
98 base.BuildCommandLine(commandLineBuilder);
106 - return commandLineBuilder.ToString();
99 }
100 }
109 -#endif
101 }
src/WixToolset.BuildTasks/HeatTask.cs
+17 -35
@@ -2,24 +2,18 @@
2
3 namespace WixToolset.BuildTasks
4 {
5 - using System;
6 - using System.Diagnostics;
7 - using System.Globalization;
8 - using System.IO;
9 - using System.Text;
10 -
5 using Microsoft.Build.Framework;
12 - using Microsoft.Build.Utilities;
6 + using WixToolset.Extensibility;
7 + using WixToolset.Extensibility.Data;
8 + using WixToolset.Extensibility.Services;
9 + using WixToolset.Harvesters;
10
14 -#if false
11 /// <summary>
12 /// A base MSBuild task to run the WiX harvester.
13 /// Specific harvester tasks should extend this class.
14 /// </summary>
19 - public abstract class HeatTask : WixToolTask
15 + public abstract class HeatTask : ToolsetTask
16 {
21 - private const string HeatToolName = "Heat.exe";
22 -
17 private bool autogenerageGuids;
18 private bool generateGuidsNow;
19 private ITaskItem outputFile;
@@ -65,15 +59,7 @@ namespace WixToolset.BuildTasks
59 set { this.transforms = value; }
60 }
61
68 - /// <summary>
69 - /// Get the name of the executable.
70 - /// </summary>
71 - /// <remarks>The ToolName is used with the ToolPath to get the location of heat.exe.</remarks>
72 - /// <value>The name of the executable.</value>
73 - protected override string ToolName
74 - {
75 - get { return HeatToolName; }
76 - }
62 + protected override string TaskShortName => "HEAT";
63
64 /// <summary>
65 /// Gets the name of the heat operation performed by the task.
@@ -85,20 +71,19 @@ namespace WixToolset.BuildTasks
71 get;
72 }
73
88 - /// <summary>
89 - /// Get the path to the executable.
90 - /// </summary>
91 - /// <remarks>GetFullPathToTool is only called when the ToolPath property is not set (see the ToolName remarks above).</remarks>
92 - /// <returns>The full path to the executable or simply heat.exe if it's expected to be in the system path.</returns>
93 - protected override string GenerateFullPathToTool()
74 + protected override void ExecuteCore(IWixToolsetServiceProvider serviceProvider, IMessageListener listener, string commandLineString)
75 {
95 - // If there's not a ToolPath specified, it has to be in the system path.
96 - if (String.IsNullOrEmpty(this.ToolPath))
97 - {
98 - return HeatToolName;
99 - }
76 + this.Log.LogMessage(MessageImportance.Normal, "heat.exe " + commandLineString);
77 +
78 + var messaging = serviceProvider.GetService<IMessaging>();
79 + messaging.SetListener(listener);
80 +
81 + var arguments = serviceProvider.GetService<ICommandLineArguments>();
82 + arguments.Populate(commandLineString);
83
101 - return Path.Combine(Path.GetFullPath(this.ToolPath), HeatToolName);
84 + var commandLine = HeatCommandLineFactory.CreateCommandLine(serviceProvider, true);
85 + var command = commandLine.ParseStandardCommandLine(arguments);
86 + command?.Execute();
87 }
88
89 /// <summary>
@@ -110,14 +95,11 @@ namespace WixToolset.BuildTasks
95
96 commandLineBuilder.AppendIfTrue("-ag", this.AutogenerateGuids);
97 commandLineBuilder.AppendIfTrue("-gg", this.GenerateGuidsNow);
113 - commandLineBuilder.AppendIfTrue("-nologo", this.NoLogo);
98 commandLineBuilder.AppendIfTrue("-sfrag", this.SuppressFragments);
99 commandLineBuilder.AppendIfTrue("-suid", this.SuppressUniqueIds);
116 - commandLineBuilder.AppendArrayIfNotNull("-sw", this.SuppressSpecificWarnings);
100 commandLineBuilder.AppendArrayIfNotNull("-t ", this.Transforms);
101 commandLineBuilder.AppendTextIfNotNull(this.AdditionalOptions);
102 commandLineBuilder.AppendSwitchIfNotNull("-out ", this.OutputFile);
103 }
104 }
122 -#endif
105 }
src/WixToolset.BuildTasks/ToolsetTask.cs new
+105
@@ -0,0 +1,105 @@
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
4 +{
5 + using System;
6 + using System.Runtime.InteropServices;
7 + using Microsoft.Build.Utilities;
8 + using WixToolset.Core;
9 + using WixToolset.Data;
10 + using WixToolset.Extensibility;
11 + using WixToolset.Extensibility.Services;
12 +
13 + public abstract class ToolsetTask : Task
14 + {
15 + /// <summary>
16 + /// Gets or sets additional options that are appended the the tool command-line.
17 + /// </summary>
18 + /// <remarks>
19 + /// This allows the task to support extended options in the tool which are not
20 + /// explicitly implemented as properties on the task.
21 + /// </remarks>
22 + public string AdditionalOptions { get; set; }
23 +
24 + /// <summary>
25 + /// Gets or sets whether to display the logo.
26 + /// </summary>
27 + public bool NoLogo { get; set; }
28 +
29 + /// <summary>
30 + /// Gets or sets whether all warnings should be suppressed.
31 + /// </summary>
32 + public bool SuppressAllWarnings { get; set; }
33 +
34 + /// <summary>
35 + /// Gets or sets a list of specific warnings to be suppressed.
36 + /// </summary>
37 + public string[] SuppressSpecificWarnings { get; set; }
38 +
39 + /// <summary>
40 + /// Gets or sets whether all warnings should be treated as errors.
41 + /// </summary>
42 + public bool TreatWarningsAsErrors { get; set; }
43 +
44 + /// <summary>
45 + /// Gets or sets a list of specific warnings to treat as errors.
46 + /// </summary>
47 + public string[] TreatSpecificWarningsAsErrors { get; set; }
48 +
49 + /// <summary>
50 + /// Gets or sets whether to display verbose output.
51 + /// </summary>
52 + public bool VerboseOutput { get; set; }
53 +
54 + public override bool Execute()
55 + {
56 + var serviceProvider = WixToolsetServiceProviderFactory.CreateServiceProvider();
57 +
58 + var listener = new MsbuildMessageListener(this.Log, this.TaskShortName, this.BuildEngine.ProjectFileOfTaskNode);
59 +
60 + try
61 + {
62 + var commandLineBuilder = new WixCommandLineBuilder();
63 + this.BuildCommandLine(commandLineBuilder);
64 +
65 + var commandLineString = commandLineBuilder.ToString();
66 + this.ExecuteCore(serviceProvider, listener, commandLineString);
67 + }
68 + catch (WixException e)
69 + {
70 + listener.Write(e.Error);
71 + }
72 + catch (Exception e)
73 + {
74 + this.Log.LogErrorFromException(e, showStackTrace: true, showDetail: true, null);
75 +
76 + if (e is NullReferenceException || e is SEHException)
77 + {
78 + throw;
79 + }
80 + }
81 +
82 + return !this.Log.HasLoggedErrors;
83 + }
84 +
85 + /// <summary>
86 + /// Builds a command line from options in this and derivative tasks.
87 + /// </summary>
88 + /// <remarks>
89 + /// Derivative classes should call BuildCommandLine() on the base class to ensure that common command line options are added to the command.
90 + /// </remarks>
91 + protected virtual void BuildCommandLine(WixCommandLineBuilder commandLineBuilder)
92 + {
93 + commandLineBuilder.AppendIfTrue("-nologo", this.NoLogo);
94 + commandLineBuilder.AppendArrayIfNotNull("-sw ", this.SuppressSpecificWarnings);
95 + commandLineBuilder.AppendIfTrue("-sw", this.SuppressAllWarnings);
96 + commandLineBuilder.AppendIfTrue("-v", this.VerboseOutput);
97 + commandLineBuilder.AppendArrayIfNotNull("-wx ", this.TreatSpecificWarningsAsErrors);
98 + commandLineBuilder.AppendIfTrue("-wx", this.TreatWarningsAsErrors);
99 + }
100 +
101 + protected abstract void ExecuteCore(IWixToolsetServiceProvider serviceProvider, IMessageListener messageListener, string commandLineString);
102 +
103 + protected abstract string TaskShortName { get; }
104 + }
105 +}
src/WixToolset.BuildTasks/WixToolset.BuildTasks.csproj
+2 -1
@@ -31,6 +31,7 @@
31 <PackageReference Include="WixToolset.Core.Burn" Version="4.0.*" />
32 <PackageReference Include="WixToolset.Core.WindowsInstaller" Version="4.0.*" />
33 <PackageReference Include="WixToolset.Dtf.WindowsInstaller" Version="4.0.*" />
34 + <PackageReference Include="WixToolset.Harvesters" Version="4.0.*" />
35 </ItemGroup>
36
37 <ItemGroup>
@@ -39,7 +40,7 @@
40 </ItemGroup>
41
42 <ItemGroup>
42 - <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-18618-05" PrivateAssets="All" />
43 + <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
44 <PackageReference Include="Nerdbank.GitVersioning" Version="2.1.65" PrivateAssets="All" />
45 </ItemGroup>
46 </Project>
src/WixToolset.BuildTasks/wix.harvest.targets
+4 -10
@@ -7,7 +7,7 @@
7 <!-- These properties can be overridden to support non-default installations. -->
8 <PropertyGroup>
9 <WixTargetsPath Condition=" '$(WixTargetsPath)' == '' ">$(MSBuildThisFileFullPath)</WixTargetsPath>
10 - <WixTasksPath Condition=" '$(WixTasksPath)' == '' ">$(WixTargetsPath)WixTasks.dll</WixTasksPath>
10 + <WixTasksPath Condition=" '$(WixTasksPath)' == '' ">$(WixTargetsPath)WixToolset.BuildTasks.dll</WixTasksPath>
11 </PropertyGroup>
12
13 <!-- These tasks are extensions for harvesting WiX source code from other sources. -->
@@ -260,10 +260,9 @@
260 Condition=" $(EnableProjectHarvesting) and ('@(HeatProject)' != '' or '@(HarvestProject)' != '') ">
261
262 <HeatProject
263 - NoLogo="$(HarvestProjectsNoLogo)"
263 + NoLogo="true"
264 SuppressAllWarnings="$(HarvestProjectsSuppressAllWarnings)"
265 SuppressSpecificWarnings="$(HarvestProjectsSuppressSpecificWarnings)"
266 - ToolPath="$(WixToolPath)"
266 TreatWarningsAsErrors="$(HarvestProjectsTreatWarningsAsErrors)"
267 TreatSpecificWarningsAsErrors="$(HarvestProjectsTreatSpecificWarningsAsErrors)"
268 VerboseOutput="$(HarvestProjectsVerboseOutput)"
@@ -280,7 +279,6 @@
279 ProjectName="%(_AllHeatProjects.ProjectName)"
280 Configuration="%(_AllHeatProjects.Configuration)"
281 Platform="%(_AllHeatProjects.Platform)"
283 - RunAsSeparateProcess="$(RunWixToolsOutOfProc)"
282 GenerateWixVariables="$(HarvestProjectsGenerateWixVariables)"
283 AdditionalOptions="$(HarvestProjectsAdditionalOptions)">
284
@@ -347,10 +345,9 @@
345 Condition=" '@(HarvestDirectory)' != '' ">
346
347 <HeatDirectory
350 - NoLogo="$(HarvestDirectoryNoLogo)"
348 + NoLogo="true"
349 SuppressAllWarnings="$(HarvestDirectorySuppressAllWarnings)"
350 SuppressSpecificWarnings="$(HarvestDirectorySuppressSpecificWarnings)"
353 - ToolPath="$(WixToolPath)"
351 TreatWarningsAsErrors="$(HarvestDirectoryTreatWarningsAsErrors)"
352 TreatSpecificWarningsAsErrors="$(HarvestDirectoryTreatSpecificWarningsAsErrors)"
353 VerboseOutput="$(HarvestDirectoryVerboseOutput)"
@@ -365,7 +362,6 @@
362 DirectoryRefId="%(HarvestDirectory.DirectoryRefId)"
363 KeepEmptyDirectories="%(HarvestDirectory.KeepEmptyDirectories)"
364 PreprocessorVariable="%(HarvestDirectory.PreprocessorVariable)"
368 - RunAsSeparateProcess="$(RunWixToolsOutOfProc)"
365 SuppressCom="%(HarvestDirectory.SuppressCom)"
366 SuppressRootDirectory="%(HarvestDirectory.SuppressRootDirectory)"
367 SuppressRegistry="%(HarvestDirectory.SuppressRegistry)"
@@ -423,10 +419,9 @@
419 Condition=" '@(HarvestFile)' != '' ">
420
421 <HeatFile
426 - NoLogo="$(HarvestFileNoLogo)"
422 + NoLogo="true"
423 SuppressAllWarnings="$(HarvestFileSuppressAllWarnings)"
424 SuppressSpecificWarnings="$(HarvestFileSuppressSpecificWarnings)"
429 - ToolPath="$(WixToolPath)"
425 TreatWarningsAsErrors="$(HarvestFileTreatWarningsAsErrors)"
426 TreatSpecificWarningsAsErrors="$(HarvestFileTreatSpecificWarningsAsErrors)"
427 VerboseOutput="$(HarvestFileVerboseOutput)"
@@ -440,7 +435,6 @@
435 ComponentGroupName="%(HarvestFile.ComponentGroupName)"
436 DirectoryRefId="%(HarvestFile.DirectoryRefId)"
437 PreprocessorVariable="%(HarvestFile.PreprocessorVariable)"
443 - RunAsSeparateProcess="$(RunWixToolsOutOfProc)"
438 SuppressCom="%(HarvestFile.SuppressCom)"
439 SuppressRegistry="%(HarvestFile.SuppressRegistry)"
440 SuppressRootDirectory="%(HarvestFile.SuppressRootDirectory)"
src/WixToolset.BuildTasks/wix.targets
+1 -2
@@ -122,8 +122,7 @@
122 </PropertyGroup>
123
124 <PropertyGroup>
125 - <WixToolDir Condition=" '$(WixToolDir)' == ''">$(WixBinDir)</WixToolDir>
126 - <WixExtDir Condition=" '$(WixExtDir)' == ''">$(WixToolDir)</WixExtDir>
125 + <WixExtDir Condition=" '$(WixExtDir)' == ''">$(WixBinDir)</WixExtDir>
126 </PropertyGroup>
127
128 <!--
src/WixToolset.Tools.Core/WixToolset.Tools.Core.csproj
+1 -1
@@ -15,7 +15,7 @@
15 </ItemGroup>
16
17 <ItemGroup>
18 - <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-18618-05" PrivateAssets="All"/>
18 + <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
19 <PackageReference Include="Nerdbank.GitVersioning" Version="2.1.65" PrivateAssets="All" />
20 </ItemGroup>
21 </Project>
src/test/WixToolsetTest.BuildTasks/MsbuildHeatFixture.cs new
+75
@@ -0,0 +1,75 @@
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 WixToolsetTest.BuildTasks
4 +{
5 + using System;
6 + using System.IO;
7 + using System.Linq;
8 + using WixBuildTools.TestSupport;
9 + using WixToolset.BuildTasks;
10 + using WixToolset.Core.TestPackage;
11 + using WixToolset.Data;
12 + using WixToolset.Data.Tuples;
13 + using Xunit;
14 +
15 + public class MsbuildHeatFixture
16 + {
17 + private static readonly string WixTargetsPath = Path.Combine(Path.GetDirectoryName(new Uri(typeof(HeatTask).Assembly.CodeBase).AbsolutePath), "wix.targets");
18 +
19 + [Fact]
20 + public void CanBuildHeatFilePackage()
21 + {
22 + var projectPath = TestData.Get(@"TestData\HeatFilePackage\HeatFilePackage.wixproj");
23 +
24 + using (var fs = new DisposableFileSystem())
25 + {
26 + var baseFolder = fs.GetFolder();
27 + var binFolder = Path.Combine(baseFolder, @"bin\");
28 + var intermediateFolder = Path.Combine(baseFolder, @"obj\");
29 +
30 + var result = MsbuildRunner.Execute(projectPath, new[]
31 + {
32 + $"-p:WixTargetsPath={WixTargetsPath}",
33 + $"-p:IntermediateOutputPath={intermediateFolder}",
34 + $"-p:OutputPath={binFolder}"
35 + });
36 + result.AssertSuccess();
37 +
38 + var heatCommandLines = result.Output.Where(line => line.TrimStart().StartsWith("heat.exe file"));
39 + Assert.Single(heatCommandLines);
40 +
41 + var warnings = result.Output.Where(line => line.Contains(": warning"));
42 + Assert.Empty(warnings);
43 +
44 + var generatedFilePath = Path.Combine(intermediateFolder, @"_HeatFilePackage_file.wxs");
45 + Assert.True(File.Exists(generatedFilePath));
46 +
47 + var generatedContents = File.ReadAllText(generatedFilePath);
48 + var testXml = generatedContents.GetTestXml();
49 + Assert.Equal(@"<Wix>" +
50 + "<Fragment>" +
51 + "<DirectoryRef Id='INSTALLFOLDER'>" +
52 + "<Component Id='HeatFilePackage.wixproj' Guid='*'>" +
53 + "<File Id='HeatFilePackage.wixproj' KeyPath='yes' Source='SourceDir\\HeatFilePackage.wixproj' />" +
54 + "</Component>" +
55 + "</DirectoryRef>" +
56 + "</Fragment>" +
57 + "<Fragment>" +
58 + "<ComponentGroup Id='ProductComponents'>" +
59 + "<ComponentRef Id='HeatFilePackage.wixproj' />" +
60 + "</ComponentGroup>" +
61 + "</Fragment>" +
62 + "</Wix>", testXml);
63 +
64 + var pdbPath = Path.Combine(binFolder, "HeatFilePackage.wixpdb");
65 + Assert.True(File.Exists(pdbPath));
66 +
67 + var intermediate = Intermediate.Load(pdbPath);
68 + var section = intermediate.Sections.Single();
69 +
70 + var fileTuple = section.Tuples.OfType<FileTuple>().Single();
71 + Assert.Equal(@"SourceDir\HeatFilePackage.wixproj", fileTuple[FileTupleFields.Source].PreviousValue.AsPath().Path);
72 + }
73 + }
74 + }
75 +}
src/test/WixToolsetTest.BuildTasks/TestData/HeatFilePackage/HeatFilePackage.wixproj new
+56
@@ -0,0 +1,56 @@
1 +<?xml version="1.0" encoding="utf-8"?>
2 +<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3 + <PropertyGroup>
4 + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5 + <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
6 + </PropertyGroup>
7 +
8 + <PropertyGroup>
9 + <ProjectGuid>7fb77005-c6e0-454f-8c2d-0a4a79c918ba</ProjectGuid>
10 + </PropertyGroup>
11 +
12 + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
13 + <PlatformName>$(Platform)</PlatformName>
14 + <OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
15 + <DefineConstants>Debug</DefineConstants>
16 + </PropertyGroup>
17 + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
18 + <PlatformName>$(Platform)</PlatformName>
19 + <OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
20 + </PropertyGroup>
21 + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
22 + <PlatformName>$(Platform)</PlatformName>
23 + <OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
24 + <DefineConstants>Debug</DefineConstants>
25 + </PropertyGroup>
26 + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
27 + <PlatformName>$(Platform)</PlatformName>
28 + <OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
29 + </PropertyGroup>
30 +
31 + <ItemGroup>
32 + <Compile Include="Package.wxs" />
33 + </ItemGroup>
34 +
35 + <ItemGroup>
36 + <BindInputPaths Include="." />
37 + </ItemGroup>
38 +
39 + <PropertyGroup>
40 + <HarvestFileSuppressUniqueIds>true</HarvestFileSuppressUniqueIds>
41 + </PropertyGroup>
42 +
43 + <ItemGroup>
44 + <HarvestFile Include="HeatFilePackage.wixproj">
45 + <ComponentGroupName>ProductComponents</ComponentGroupName>
46 + <DirectoryRefId>INSTALLFOLDER</DirectoryRefId>
47 + <SuppressRootDirectory>true</SuppressRootDirectory>
48 + </HarvestFile>
49 + </ItemGroup>
50 +
51 + <Import Project="$(WixTargetsPath)" Condition=" '$(WixTargetsPath)' != '' " />
52 + <Import Project="$(MSBuildExtensionsPath32)\WixToolset\v4.x\wix.targets" Condition=" '$(WixTargetsPath)' == '' AND Exists('$(MSBuildExtensionsPath32)\WixToolset\v4.x\wix.targets') " />
53 + <Target Name="EnsureWixToolsetInstalled" Condition=" '$(WixTargetsImported)' != 'true' ">
54 + <Error Text="WiX Toolset build tools (v4.0 or later) must be installed to build this project. To download the WiX Toolset, go to http://wixtoolset.org/releases/." />
55 + </Target>
56 +</Project>
\ No newline at end of file
src/test/WixToolsetTest.BuildTasks/TestData/HeatFilePackage/Package.wxs new
+21
@@ -0,0 +1,21 @@
1 +<?xml version="1.0" encoding="utf-8"?>
2 +
3 +<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
4 + <Product Id="*" Name="HeatFilePackage" Language="1033" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="047730a5-30fe-4a62-a520-da9381b8226a">
5 + <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
6 +
7 + <MediaTemplate />
8 +
9 + <Feature Id="ProductFeature" Title="HeatFileFeature">
10 + <ComponentGroupRef Id="ProductComponents" />
11 + </Feature>
12 + </Product>
13 +
14 + <Fragment>
15 + <Directory Id="TARGETDIR" Name="SourceDir">
16 + <Directory Id="ProgramFilesFolder">
17 + <Directory Id="INSTALLFOLDER" Name="MsiPackage" />
18 + </Directory>
19 + </Directory>
20 + </Fragment>
21 +</Wix>
src/test/WixToolsetTest.BuildTasks/WixToolsetTest.BuildTasks.csproj
+9
@@ -9,6 +9,14 @@
9 </PropertyGroup>
10
11 <ItemGroup>
12 + <Content Include="TestData\HeatFilePackage\HeatFilePackage.wixproj" CopyToOutputDirectory="PreserveNewest" />
13 + <Content Include="TestData\HeatFilePackage\Package.wxs" CopyToOutputDirectory="PreserveNewest" />
14 + <Content Include="TestData\MultiCulturalMsiPackage\MsiPackage\MsiPackage.wixproj" CopyToOutputDirectory="PreserveNewest" />
15 + <Content Include="TestData\MultiCulturalMsiPackage\MsiPackage\Package.de-de.wxl" CopyToOutputDirectory="PreserveNewest" />
16 + <Content Include="TestData\MultiCulturalMsiPackage\MsiPackage\Package.en-us.wxl" CopyToOutputDirectory="PreserveNewest" />
17 + <Content Include="TestData\MultiCulturalMsiPackage\MsiPackage\Package.wxs" CopyToOutputDirectory="PreserveNewest" />
18 + <Content Include="TestData\MultiCulturalMsiPackage\MsiPackage\PackageComponents.wxs" CopyToOutputDirectory="PreserveNewest" />
19 + <Content Include="TestData\MultiCulturalMsiPackage\MsiPackage\data\test.txt" CopyToOutputDirectory="PreserveNewest" />
20 <Content Include="TestData\SimpleMsiPackage\MsiPackage\MsiPackage.wixproj" CopyToOutputDirectory="PreserveNewest" />
21 <Content Include="TestData\SimpleMsiPackage\MsiPackage\Package.en-us.wxl" CopyToOutputDirectory="PreserveNewest" />
22 <Content Include="TestData\SimpleMsiPackage\MsiPackage\Package.wxs" CopyToOutputDirectory="PreserveNewest" />
@@ -24,6 +32,7 @@
32 <PackageReference Include="Microsoft.Build.Tasks.Core" Version="14.3" Condition="'$(TargetFramework)'=='net461' or '$(TargetFramework)'=='net472'" />
33 <PackageReference Include="Microsoft.Build.Tasks.Core" Version="15.7.179" Condition="'$(TargetFramework)'=='netcoreapp2.1' " />
34 <PackageReference Include="WixBuildTools.TestSupport" Version="4.0.*" />
35 + <PackageReference Include="WixToolset.Core.TestPackage" Version="4.0.*" />
36 </ItemGroup>
37
38 <ItemGroup>
src/wix/wix.csproj
+1 -1
@@ -26,7 +26,7 @@
26 </ItemGroup>
27
28 <ItemGroup>
29 - <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-18618-05" PrivateAssets="All" />
29 + <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
30 <PackageReference Include="Nerdbank.GitVersioning" Version="2.1.65" PrivateAssets="All" />
31 </ItemGroup>
32 </Project>
src/wixcop/WixCop.csproj
+1 -1
@@ -25,7 +25,7 @@
25 </ItemGroup>
26
27 <ItemGroup>
28 - <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-18618-05" PrivateAssets="All"/>
28 + <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
29 <PackageReference Include="Nerdbank.GitVersioning" Version="2.1.65" PrivateAssets="All" />
30 </ItemGroup>
31 </Project>