@joebigelow / wix-1 / commits / 5567239a

Run wix.exe out of proc

"wix build" will load assemblies to read metadata which can cause the assemblies to get locked in the process. Since MSBuild keeps build processes alive this can cause work done by in-proc MSBuild tasks (like the WixBuild) to get stuck. Moving the "wix build" out of proc avoids any of those issues. Moving out of proc also allows the WiX tasks to be AnyCPU which simplifies the wix.targets (although did need to add code to find the .NET Framework wix.exe). Fixes 6595

Rob Mensching committed Oct 6, 2022 at 11:59 UTC 5567239a9411aac769a34f2c65b80a523a577ad7
21 files changed +226 -367
src/internal/WixBuildTools.TestSupport/MsbuildUtilities.cs
+3 -10
@@ -17,7 +17,7 @@ namespace WixToolsetTest.Sdk
17
18 public static class MsbuildUtilities
19 {
20 - public static MsbuildRunnerResult BuildProject(BuildSystem buildSystem, string projectPath, string[] arguments = null, string configuration = "Release", bool? outOfProc = null, string verbosityLevel = "normal", bool suppressValidation = true)
20 + public static MsbuildRunnerResult BuildProject(BuildSystem buildSystem, string projectPath, string[] arguments = null, string configuration = "Release", string verbosityLevel = "normal", bool suppressValidation = true)
21 {
22 var allArgs = new List<string>
23 {
@@ -30,11 +30,6 @@ namespace WixToolsetTest.Sdk
30 $"-bl:{Path.ChangeExtension(projectPath, ".binlog")}"
31 };
32
33 - if (outOfProc.HasValue)
34 - {
35 - allArgs.Add($"-p:RunWixToolsOutOfProc={outOfProc.Value}");
36 - }
37 -
33 if (arguments != null)
34 {
35 allArgs.AddRange(arguments);
@@ -96,11 +91,9 @@ namespace WixToolsetTest.Sdk
91 }
92 }
93
99 - public static IEnumerable<string> GetToolCommandLines(MsbuildRunnerResult result, string toolName, string operation, BuildSystem buildSystem, bool? outOfProc = null)
94 + public static IEnumerable<string> GetToolCommandLines(MsbuildRunnerResult result, string toolName, string operation, BuildSystem buildSystem)
95 {
101 - var expectedOutOfProc = buildSystem == BuildSystem.DotNetCoreSdk || outOfProc.HasValue && outOfProc.Value;
102 - var expectedToolExe = !expectedOutOfProc ? $"({toolName}.exe)" :
103 - buildSystem == BuildSystem.DotNetCoreSdk ? $"{toolName}.dll\"" : $"{toolName}.exe";
96 + var expectedToolExe = buildSystem == BuildSystem.DotNetCoreSdk ? $"{toolName}.dll\"" : $"{toolName}.exe";
97 var expectedToolCommand = $"{expectedToolExe} {operation}";
98 return result.Output.Where(line => line.Contains(expectedToolCommand));
99 }
src/internal/internal.cmd
+22 -3
@@ -2,10 +2,21 @@
2 @pushd %~dp0
3
4 @set _C=Debug
5 +@set _L=%~dp0..\..\build\logs
6 +
7 :parse_args
8 @if /i "%1"=="release" set _C=Release
9 +@if /i "%1"=="inc" set _INC=1
10 +@if /i "%1"=="clean" set _CLEAN=1
11 @if not "%1"=="" shift & goto parse_args
12
13 +@set _B=%~dp0..\..\build\wix\%_C%
14 +
15 +:: Clean
16 +
17 +@if "%_INC%"=="" call :clean
18 +@if NOT "%_CLEAN%"=="" goto :end
19 +
20 @echo Building internal %_C%
21
22 :: internal
@@ -14,10 +25,18 @@ nuget restore || exit /b
25 :: dotnet pack -c %_C% WixBuildTools.MsgGen\WixBuildTools.MsgGen.csproj || exit /b
26 :: dotnet pack -c %_C% WixBuildTools.XsdGen\WixBuildTools.XsdGen.csproj || exit /b
27
17 -msbuild -t:Pack WixBuildTools.TestSupport\WixBuildTools.TestSupport.csproj -p:Configuration=%_C% -nologo -m -warnaserror -bl:..\..\build\logs\internal_build.binlog || exit /b
28 +msbuild internal_t.proj -p:Configuration=%_C% -nologo -warnaserror -bl:%_L%\internal_build.binlog || exit /b
29 +
30 +@goto :end
31
19 -msbuild -t:Build WixBuildTools.TestSupport.Native\WixBuildTools.TestSupport.Native.vcxproj -p:Configuration=%_C%;Platform=x86 -nologo || exit /b
20 -msbuild -t:Build WixBuildTools.TestSupport.Native\WixBuildTools.TestSupport.Native.vcxproj -p:Configuration=%_C%;Platform=x64 -nologo || exit /b
32 +:clean
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 +@rd /s/q "%USERPROFILE%\.nuget\packages\wixbuildtools.testsupport" 2> nul
37 +@rd /s/q "%USERPROFILE%\.nuget\packages\wixbuildtools.testsupport.native" 2> nul
38 +@exit /b
39
40 +:end
41 @popd
42 @endlocal
src/internal/internal_t.proj new
+7
@@ -0,0 +1,7 @@
1 +<Project Sdk="Microsoft.Build.Traversal">
2 + <ItemGroup>
3 + <ProjectReference Include="WixBuildTools.TestSupport\WixBuildTools.TestSupport.csproj" Targets="Pack" />
4 + <ProjectReference Include="WixBuildTools.TestSupport.Native\WixBuildTools.TestSupport.Native.vcxproj" Properties="Platform=x86" />
5 + <ProjectReference Include="WixBuildTools.TestSupport.Native\WixBuildTools.TestSupport.Native.vcxproj" Properties="Platform=x64" />
6 + </ItemGroup>
7 +</Project>
src/testresultfilelist.txt
+1 -2
@@ -2,8 +2,7 @@ build/logs/TestResults/api.trx
2 build/logs/TestResults/burn.trx
3 build/logs/TestResults/libs.trx
4 build/logs/TestResults/tools.trx
5 -build/logs/TestResults/wix_prepublish.trx
6 -build/logs/TestResults/wix_postpublish.trx
5 +build/logs/TestResults/wix.trx
6 build/logs/TestResults/WixToolsetTest.Bal.trx
7 build/logs/TestResults/WixToolsetTest.BurnE2E.trx
8 build/logs/TestResults/WixToolsetTest.Dnc.HostGenerator.trx
src/tools/WixToolset.HeatTasks/WixToolset.HeatTasks.csproj
-1
@@ -7,7 +7,6 @@
7 <Title>WiX Toolset Heat MSBuild Tasks</Title>
8 <DebugType>embedded</DebugType>
9 <PublishRepositoryUrl>true</PublishRepositoryUrl>
10 - <!-- https://github.com/Microsoft/msbuild/issues/2360 -->
10 <PlatformTarget>AnyCPU</PlatformTarget>
11 </PropertyGroup>
12
src/tools/test/WixToolsetTest.HeatTasks/MsbuildHeatFixture.cs
+4 -4
@@ -43,7 +43,7 @@ namespace WixToolsetTest.Sdk
43 });
44 result.AssertSuccess();
45
46 - var heatCommandLines = MsbuildUtilities.GetToolCommandLines(result, "heat", "file", buildSystem, true);
46 + var heatCommandLines = MsbuildUtilities.GetToolCommandLines(result, "heat", "file", buildSystem);
47 Assert.Single(heatCommandLines);
48
49 var warnings = result.Output.Where(line => line.Contains(": warning")).ToArray();
@@ -99,7 +99,7 @@ namespace WixToolsetTest.Sdk
99 });
100 result.AssertSuccess();
101
102 - var heatCommandLines = MsbuildUtilities.GetToolCommandLines(result, "heat", "file", buildSystem, true);
102 + var heatCommandLines = MsbuildUtilities.GetToolCommandLines(result, "heat", "file", buildSystem);
103 Assert.Equal(2, heatCommandLines.Count());
104
105 var warnings = result.Output.Where(line => line.Contains(": warning")).ToArray();
@@ -185,7 +185,7 @@ namespace WixToolsetTest.Sdk
185 });
186 result.AssertSuccess();
187
188 - var heatCommandLines = MsbuildUtilities.GetToolCommandLines(result, "heat", "project", buildSystem, true);
188 + var heatCommandLines = MsbuildUtilities.GetToolCommandLines(result, "heat", "project", buildSystem);
189 var heatCommandLine = Assert.Single(heatCommandLines);
190
191 if (useToolsVersion && buildSystem != BuildSystem.DotNetCoreSdk)
@@ -306,7 +306,7 @@ namespace WixToolsetTest.Sdk
306 });
307 result.AssertSuccess();
308
309 - var heatCommandLines = MsbuildUtilities.GetToolCommandLines(result, "heat", "project", buildSystem, true);
309 + var heatCommandLines = MsbuildUtilities.GetToolCommandLines(result, "heat", "project", buildSystem);
310 var heatCommandLine = Assert.Single(heatCommandLines);
311
312 if (useToolsVersion && buildSystem != BuildSystem.DotNetCoreSdk)
src/wix/Directory.Build.props
+4
@@ -7,4 +7,8 @@
7 </PropertyGroup>
8
9 <Import Project="..\Directory.Build.props" />
10 +
11 + <PropertyGroup>
12 + <PublishRoot>$(OutputPath)publish\</PublishRoot>
13 + </PropertyGroup>
14 </Project>
src/wix/WixToolset.BuildTasks/MsbuildMessageListener.cs deleted
-68
@@ -1,68 +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 -#if !NETCOREAPP
4 -namespace WixToolset.BuildTasks
5 -{
6 - using System;
7 - using Microsoft.Build.Framework;
8 - using Microsoft.Build.Utilities;
9 - using WixToolset.Data;
10 - using WixToolset.Extensibility;
11 - using WixToolset.Extensibility.Services;
12 -
13 - public sealed class MsbuildMessageListener : IMessageListener
14 - {
15 - public MsbuildMessageListener(TaskLoggingHelper logger, string shortName, string longName)
16 - {
17 - this.Logger = logger;
18 - this.ShortAppName = shortName;
19 - this.LongAppName = longName;
20 - }
21 -
22 - public string ShortAppName { get; }
23 -
24 - public string LongAppName { get; }
25 -
26 - private TaskLoggingHelper Logger { get; }
27 -
28 - public void Write(Message message)
29 - {
30 - var code = this.ShortAppName + message.Id.ToString();
31 - var file = message.SourceLineNumbers?.FileName ?? this.LongAppName;
32 - var lineNumber = message.SourceLineNumbers?.LineNumber ?? 0;
33 - switch (message.Level)
34 - {
35 - case MessageLevel.Error:
36 - this.Logger.LogError(null, code, null, file, lineNumber, 0, 0, 0, message.ResourceNameOrFormat, message.MessageArgs);
37 - break;
38 -
39 - case MessageLevel.Verbose:
40 - this.Logger.LogMessage(null, code, null, file, lineNumber, 0, 0, 0, MessageImportance.Low, message.ResourceNameOrFormat, message.MessageArgs);
41 - break;
42 -
43 - case MessageLevel.Warning:
44 - this.Logger.LogWarning(null, code, null, file, lineNumber, 0, 0, 0, message.ResourceNameOrFormat, message.MessageArgs);
45 - break;
46 -
47 - default:
48 - if (message.Id > 0)
49 - {
50 - this.Logger.LogMessage(null, code, null, file, lineNumber, 0, 0, 0, MessageImportance.Normal, message.ResourceNameOrFormat, message.MessageArgs);
51 - }
52 - else
53 - {
54 - this.Logger.LogMessage(MessageImportance.Normal, message.ResourceNameOrFormat, message.MessageArgs);
55 - }
56 - break;
57 - }
58 - }
59 -
60 - public void Write(string message)
61 - {
62 - this.Logger.LogMessage(MessageImportance.Low, message);
63 - }
64 -
65 - public MessageLevel CalculateMessageLevel(IMessaging messaging, Message message, MessageLevel defaultMessageLevel) => defaultMessageLevel;
66 - }
67 -}
68 -#endif
src/wix/WixToolset.BuildTasks/ToolsetTask.cs
+71 -50
@@ -7,15 +7,8 @@ namespace WixToolset.BuildTasks
7 using System.Runtime.InteropServices;
8 using Microsoft.Build.Utilities;
9
10 - public abstract partial class ToolsetTask : ToolTask
10 + public abstract class ToolsetTask : ToolTask
11 {
12 -#if NETCOREAPP
13 - private static readonly string DotnetFullPath = Environment.GetEnvironmentVariable("DOTNET_HOST_PATH") ?? "dotnet";
14 - private static readonly string ThisDllPath = typeof(ToolsetTask).Assembly.Location;
15 -#else
16 - private static readonly string ThisDllPath = new Uri(typeof(ToolsetTask).Assembly.CodeBase).AbsolutePath;
17 -#endif
18 -
12 /// <summary>
13 /// Gets or sets additional options that are appended the the tool command-line.
14 /// </summary>
@@ -30,12 +23,6 @@ namespace WixToolset.BuildTasks
23 /// </summary>
24 public bool NoLogo { get; set; }
25
33 - /// <summary>
34 - /// Gets or sets a flag indicating whether the task
35 - /// should be run as separate process or in-proc.
36 - /// </summary>
37 - public virtual bool RunAsSeparateProcess { get; set; }
38 -
26 /// <summary>
27 /// Gets or sets whether all warnings should be suppressed.
28 /// </summary>
@@ -61,20 +48,6 @@ namespace WixToolset.BuildTasks
48 /// </summary>
49 public bool VerboseOutput { get; set; }
50
64 - private string DefaultToolFullPath => Path.Combine(Path.GetDirectoryName(ThisDllPath), this.ToolExe);
65 -
66 - private string ToolFullPath
67 - {
68 - get
69 - {
70 - if (String.IsNullOrEmpty(this.ToolPath))
71 - {
72 - return this.DefaultToolFullPath;
73 - }
74 - return Path.Combine(this.ToolPath, this.ToolExe);
75 - }
76 - }
77 -
51 /// <summary>
52 /// Get the path to the executable.
53 /// </summary>
@@ -85,29 +58,22 @@ namespace WixToolset.BuildTasks
58 /// </remarks>
59 protected sealed override string GenerateFullPathToTool()
60 {
61 + var defaultToolFullPath = this.GetDefaultToolFullPath();
62 +
63 #if NETCOREAPP
89 - if (IsSelfExecutable(this.DefaultToolFullPath, out var toolFullPath))
64 + // If we're pointing at an executable use that.
65 + if (IsSelfExecutable(defaultToolFullPath, out var finalToolFullPath))
66 {
91 - return toolFullPath;
67 + return finalToolFullPath;
68 }
93 - return DotnetFullPath;
69 +
70 + // Otherwise, use "dotnet.exe" to run an assembly dll.
71 + return Environment.GetEnvironmentVariable("DOTNET_HOST_PATH") ?? "dotnet";
72 #else
95 - if (!this.RunAsSeparateProcess)
96 - {
97 - // We need to return a path that exists, so if we're not actually going to run the tool then just return this dll path.
98 - return ThisDllPath;
99 - }
100 - return this.DefaultToolFullPath;
73 + return defaultToolFullPath;
74 #endif
75 }
76
104 - protected sealed override string GenerateResponseFileCommands()
105 - {
106 - var commandLineBuilder = new WixCommandLineBuilder();
107 - this.BuildCommandLine(commandLineBuilder);
108 - return commandLineBuilder.ToString();
109 - }
110 -
77 /// <summary>
78 /// Builds a command line from options in this and derivative tasks.
79 /// </summary>
@@ -124,33 +90,88 @@ namespace WixToolset.BuildTasks
90 commandLineBuilder.AppendIfTrue("-wx", this.TreatWarningsAsErrors);
91 }
92
93 + protected sealed override string GenerateResponseFileCommands()
94 + {
95 + var commandLineBuilder = new WixCommandLineBuilder();
96 + this.BuildCommandLine(commandLineBuilder);
97 + return commandLineBuilder.ToString();
98 + }
99 +
100 #if NETCOREAPP
101 protected override string GenerateCommandLineCommands()
102 {
130 - if (IsSelfExecutable(this.ToolFullPath, out var toolFullPath))
103 + // If the target tool path is an executable, we don't need to add anything to the command-line.
104 + var toolFullPath = this.GetToolFullPath();
105 +
106 + if (IsSelfExecutable(toolFullPath, out var finalToolFullPath))
107 {
108 return null;
109 }
134 - else
110 + else // we're using "dotnet.exe" to run the assembly so add "exec" plus path to the command-line.
111 {
136 - return $"exec \"{toolFullPath}\"";
112 + return $"exec \"{finalToolFullPath}\"";
113 }
114 }
115
140 - private static bool IsSelfExecutable(string proposedToolFullPath, out string toolFullPath)
116 + private static bool IsSelfExecutable(string proposedToolFullPath, out string finalToolFullPath)
117 {
118 var toolFullPathWithoutExtension = Path.Combine(Path.GetDirectoryName(proposedToolFullPath), Path.GetFileNameWithoutExtension(proposedToolFullPath));
119 var exeExtension = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ".exe" : String.Empty;
120 var exeToolFullPath = $"{toolFullPathWithoutExtension}{exeExtension}";
121 if (File.Exists(exeToolFullPath))
122 {
147 - toolFullPath = exeToolFullPath;
123 + finalToolFullPath = exeToolFullPath;
124 return true;
125 }
126
151 - toolFullPath = $"{toolFullPathWithoutExtension}.dll";
127 + finalToolFullPath = $"{toolFullPathWithoutExtension}.dll";
128 return false;
129 }
130 +#else
131 + private static string GetArchitectureFolder(string baseFolder)
132 + {
133 + // First try to find a folder that matches this task's architecture.
134 + var folder = RuntimeInformation.ProcessArchitecture.ToString().ToLowerInvariant();
135 +
136 + if (Directory.Exists(Path.Combine(baseFolder, folder)))
137 + {
138 + return folder;
139 + }
140 +
141 + // Try to fallback to "x86" folder.
142 + if (folder != "x86" && Directory.Exists(Path.Combine(baseFolder, "x86")))
143 + {
144 + return "x86";
145 + }
146 +
147 + // Return empty, even though this isn't likely to be useful.
148 + return String.Empty;
149 + }
150 +#endif
151 +
152 + private string GetDefaultToolFullPath()
153 + {
154 +#if NETCOREAPP
155 + var thisTaskFolder = Path.GetDirectoryName(typeof(ToolsetTask).Assembly.Location);
156 +
157 + return Path.Combine(thisTaskFolder, this.ToolExe);
158 +#else
159 + var thisTaskFolder = Path.GetDirectoryName(new Uri(typeof(ToolsetTask).Assembly.CodeBase).AbsolutePath);
160 +
161 + var archFolder = GetArchitectureFolder(thisTaskFolder);
162 +
163 + return Path.Combine(thisTaskFolder, archFolder, this.ToolExe);
164 #endif
165 + }
166 +
167 + private string GetToolFullPath()
168 + {
169 + if (String.IsNullOrEmpty(this.ToolPath))
170 + {
171 + return this.GetDefaultToolFullPath();
172 + }
173 +
174 + return Path.Combine(this.ToolPath, this.ToolExe);
175 + }
176 }
177 }
src/wix/WixToolset.BuildTasks/ToolsetTask_InProc.cs deleted
-79
@@ -1,79 +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 -#if !NETCOREAPP
4 -namespace WixToolset.BuildTasks
5 -{
6 - using System;
7 - using System.Runtime.InteropServices;
8 - using System.Threading;
9 - using System.Threading.Tasks;
10 - using Microsoft.Build.Framework;
11 - using WixToolset.Core;
12 - using WixToolset.Data;
13 - using WixToolset.Extensibility;
14 - using WixToolset.Extensibility.Services;
15 -
16 - public partial class ToolsetTask
17 - {
18 - protected override int ExecuteTool(string pathToTool, string responseFileCommands, string commandLineCommands)
19 - {
20 - if (this.RunAsSeparateProcess)
21 - {
22 - return base.ExecuteTool(pathToTool, responseFileCommands, commandLineCommands);
23 - }
24 -
25 - return this.ExecuteInProc($"{commandLineCommands} {responseFileCommands}");
26 - }
27 -
28 - private int ExecuteInProc(string commandLineString)
29 - {
30 - this.Log.LogMessage(MessageImportance.Normal, $"({this.ToolName}){commandLineString}");
31 -
32 - var listener = new MsbuildMessageListener(this.Log, this.TaskShortName, this.BuildEngine.ProjectFileOfTaskNode);
33 - var exitCode = -1;
34 -
35 - try
36 - {
37 - var coreProvider = WixToolsetServiceProviderFactory.CreateServiceProvider();
38 -
39 - var messaging = coreProvider.GetService<IMessaging>();
40 - messaging.SetListener(listener);
41 -
42 - exitCode = this.ExecuteCoreAsync(coreProvider, commandLineString, CancellationToken.None).GetAwaiter().GetResult();
43 - }
44 - catch (WixException e)
45 - {
46 - listener.Write(e.Error);
47 - }
48 - catch (Exception e)
49 - {
50 - this.Log.LogErrorFromException(e, showStackTrace: true, showDetail: true, null);
51 -
52 - if (e is NullReferenceException || e is SEHException)
53 - {
54 - throw;
55 - }
56 - }
57 -
58 - if (exitCode == 0 && this.Log.HasLoggedErrors)
59 - {
60 - exitCode = -1;
61 - }
62 - return exitCode;
63 - }
64 -
65 - protected sealed override void LogToolCommand(string message)
66 - {
67 - // Only log this if we're actually going to do it.
68 - if (this.RunAsSeparateProcess)
69 - {
70 - base.LogToolCommand(message);
71 - }
72 - }
73 -
74 - protected abstract Task<int> ExecuteCoreAsync(IWixToolsetCoreServiceProvider coreProvider, string commandLineString, CancellationToken cancellationToken);
75 -
76 - protected abstract string TaskShortName { get; }
77 - }
78 -}
79 -#endif
src/wix/WixToolset.BuildTasks/WixExeBaseTask.cs
+1 -1
@@ -5,7 +5,7 @@ namespace WixToolset.BuildTasks
5 /// <summary>
6 /// An MSBuild task to run WiX to update cabinet signatures in a MSI.
7 /// </summary>
8 - public abstract partial class WixExeBaseTask : ToolsetTask
8 + public abstract class WixExeBaseTask : ToolsetTask
9 {
10 protected override string ToolName => "wix.exe";
11 }
src/wix/WixToolset.BuildTasks/WixExeBaseTask_Inproc.cs deleted
-28
@@ -1,28 +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 -#if !NETCOREAPP
4 -namespace WixToolset.BuildTasks
5 -{
6 - using System;
7 - using System.Threading;
8 - using System.Threading.Tasks;
9 - using WixToolset.Core.Burn;
10 - using WixToolset.Core.WindowsInstaller;
11 - using WixToolset.Extensibility.Services;
12 -
13 - public abstract partial class WixExeBaseTask
14 - {
15 - protected override string TaskShortName => "WIX";
16 -
17 - protected override Task<int> ExecuteCoreAsync(IWixToolsetCoreServiceProvider coreProvider, string commandLineString, CancellationToken cancellationToken)
18 - {
19 - coreProvider.AddWindowsInstallerBackend()
20 - .AddBundleBackend();
21 -
22 - var commandLine = coreProvider.GetService<ICommandLine>();
23 - var command = commandLine.CreateCommand(commandLineString);
24 - return command?.ExecuteAsync(cancellationToken) ?? Task.FromResult(1);
25 - }
26 - }
27 -}
28 -#endif
src/wix/WixToolset.BuildTasks/WixToolset.BuildTasks.csproj
-11
@@ -8,8 +8,6 @@
8 <Title>WiX Toolset MSBuild Tasks</Title>
9 <DebugType>embedded</DebugType>
10 <PublishRepositoryUrl>true</PublishRepositoryUrl>
11 - <RuntimeIdentifiers Condition=" '$(RuntimeIdentifier)'=='' and '$(TargetFramework)'!='net6.0' ">win-x86;win-x64</RuntimeIdentifiers>
12 - <!-- https://github.com/Microsoft/msbuild/issues/2360 -->
11 <PlatformTarget>AnyCPU</PlatformTarget>
12 </PropertyGroup>
13
@@ -17,13 +15,4 @@
15 <PackageReference Include="WixToolset.Dtf.WindowsInstaller" />
16 <PackageReference Include="Microsoft.Build.Tasks.Core" />
17 </ItemGroup>
20 -
21 - <ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'" >
22 - <ProjectReference Include="..\WixToolset.Core\WixToolset.Core.csproj" />
23 - <ProjectReference Include="..\WixToolset.Core.Burn\WixToolset.Core.Burn.csproj" />
24 - <ProjectReference Include="..\WixToolset.Core.WindowsInstaller\WixToolset.Core.WindowsInstaller.csproj" />
25 - </ItemGroup>
26 -
27 - <ItemGroup Condition="'$(TargetFramework)'=='net6.0' ">
28 - </ItemGroup>
18 </Project>
src/wix/WixToolset.Sdk/WixToolset.Sdk.csproj
+1 -1
@@ -5,7 +5,7 @@
5 <PropertyGroup>
6 <TargetFramework>net6.0</TargetFramework>
7 <Description>WiX Toolset MSBuild integration</Description>
8 - <PublishDir>$(OutputPath)publish\WixToolset.Sdk\</PublishDir>
8 + <PublishDir>$(PublishRoot)WixToolset.Sdk\</PublishDir>
9 <NuspecFile>$(MSBuildThisFileName).nuspec</NuspecFile>
10 <NuspecBasePath>$(PublishDir)</NuspecBasePath>
11 </PropertyGroup>
src/wix/WixToolset.Sdk/tools/WixToolset.Signing.targets
-3
@@ -213,7 +213,6 @@
213 VerboseOutput="$(InscribeVerboseOutput)"
214 AdditionalOptions="$(InscribeAdditionalOptions)"
215
216 - RunAsSeparateProcess="$(RunWixToolsOutOfProc)"
216 ToolExe="$(WixToolExe)"
217 ToolPath="$(WixToolDir)" />
218 </Target>
@@ -255,7 +254,6 @@
254 VerboseOutput="$(InscribeVerboseOutput)"
255 AdditionalOptions="$(InscribeAdditionalOptions)"
256
258 - RunAsSeparateProcess="$(RunWixToolsOutOfProc)"
257 ToolExe="$(WixToolExe)"
258 ToolPath="$(WixToolDir)">
259 <Output TaskParameter="Output" ItemName="SignBundleEngine" />
@@ -304,7 +302,6 @@
302 VerboseOutput="$(InscribeVerboseOutput)"
303 AdditionalOptions="$(InscribeAdditionalOptions)"
304
307 - RunAsSeparateProcess="$(RunWixToolsOutOfProc)"
305 ToolExe="$(WixToolExe)"
306 ToolPath="$(WixToolDir)">
307 <Output TaskParameter="Output" ItemName="SignBundle" />
src/wix/WixToolset.Sdk/tools/wix.targets
+9 -37
@@ -27,10 +27,8 @@
27 <!-- These properties can be overridden to support non-default installations. -->
28 <PropertyGroup>
29 <WixBinDir Condition=" '$(WixBinDir)' == '' and '$(MSBuildRuntimeType)' == 'Core' ">$(MSBuildThisFileDirectory)net6.0\</WixBinDir>
30 - <WixBinDir Condition=" '$(WixBinDir)' == '' ">$(MSBuildThisFileDirectory)net472\x86\</WixBinDir>
31 - <WixBinDir64 Condition=" '$(WixBinDir64)' == '' and '$(MSBuildRuntimeType)' != 'Core' ">$(MSBuildThisFileDirectory)net472\x64\</WixBinDir64>
30 + <WixBinDir Condition=" '$(WixBinDir)' == '' ">$(MSBuildThisFileDirectory)net472\</WixBinDir>
31 <WixTasksPath Condition=" '$(WixTasksPath)' == '' ">$(WixBinDir)WixToolset.BuildTasks.dll</WixTasksPath>
33 - <WixTasksPath64 Condition=" '$(WixTasksPath64)' == '' and '$(WixBinDir64)' != '' ">$(WixBinDir64)WixToolset.BuildTasks.dll</WixTasksPath64>
32 </PropertyGroup>
33
34 <PropertyGroup>
@@ -147,39 +145,14 @@
145 ***********************************************************************************************
146 -->
147
150 - <!-- These tasks can be used as general-purpose build tasks. -->
151 - <UsingTask TaskName="WixBuild" Condition=" '$(WixTasksPath64)' == '' " AssemblyFile="$(WixTasksPath)" />
152 - <UsingTask TaskName="WixBuild" Condition=" '$(WixTasksPath64)' != '' " AssemblyFile="$(WixTasksPath)" Architecture="x86" />
153 - <UsingTask TaskName="WixBuild" Condition=" '$(WixTasksPath64)' != '' " AssemblyFile="$(WixTasksPath64)" Architecture="x64" />
154 -
155 - <!-- These tasks are specific to the build process defined in this file, and are not considered general-purpose build tasks. -->
156 - <UsingTask TaskName="CreateItemAvoidingInference" Condition=" '$(WixTasksPath64)' == '' " AssemblyFile="$(WixTasksPath)" />
157 - <UsingTask TaskName="CreateItemAvoidingInference" Condition=" '$(WixTasksPath64)' != '' " AssemblyFile="$(WixTasksPath)" Architecture="x86" />
158 - <UsingTask TaskName="CreateItemAvoidingInference" Condition=" '$(WixTasksPath64)' != '' " AssemblyFile="$(WixTasksPath64)" Architecture="x64" />
159 -
160 - <UsingTask TaskName="UpdateProjectReferenceMetadata" Condition=" '$(WixTasksPath64)' == '' " AssemblyFile="$(WixTasksPath)" />
161 - <UsingTask TaskName="UpdateProjectReferenceMetadata" Condition=" '$(WixTasksPath64)' != '' " AssemblyFile="$(WixTasksPath)" Architecture="x86" />
162 - <UsingTask TaskName="UpdateProjectReferenceMetadata" Condition=" '$(WixTasksPath64)' != '' " AssemblyFile="$(WixTasksPath64)" Architecture="x64" />
163 -
164 - <UsingTask TaskName="CreateProjectReferenceDefineConstantsAndBindPaths" Condition=" '$(WixTasksPath64)' == '' " AssemblyFile="$(WixTasksPath)" />
165 - <UsingTask TaskName="CreateProjectReferenceDefineConstantsAndBindPaths" Condition=" '$(WixTasksPath64)' != '' " AssemblyFile="$(WixTasksPath)" Architecture="x86" />
166 - <UsingTask TaskName="CreateProjectReferenceDefineConstantsAndBindPaths" Condition=" '$(WixTasksPath64)' != '' " AssemblyFile="$(WixTasksPath64)" Architecture="x64" />
167 -
168 - <UsingTask TaskName="WixAssignCulture" Condition=" '$(WixTasksPath64)' == '' " AssemblyFile="$(WixTasksPath)" />
169 - <UsingTask TaskName="WixAssignCulture" Condition=" '$(WixTasksPath64)' != '' " AssemblyFile="$(WixTasksPath)" Architecture="x86" />
170 - <UsingTask TaskName="WixAssignCulture" Condition=" '$(WixTasksPath64)' != '' " AssemblyFile="$(WixTasksPath64)" Architecture="x64" />
171 -
172 - <UsingTask TaskName="ReadTracking" Condition=" '$(WixTasksPath64)' == '' " AssemblyFile="$(WixTasksPath)" />
173 - <UsingTask TaskName="ReadTracking" Condition=" '$(WixTasksPath64)' != '' " AssemblyFile="$(WixTasksPath)" Architecture="x86" />
174 - <UsingTask TaskName="ReadTracking" Condition=" '$(WixTasksPath64)' != '' " AssemblyFile="$(WixTasksPath64)" Architecture="x64" />
175 -
176 - <UsingTask TaskName="ResolveWixReferences" Condition=" '$(WixTasksPath64)' == '' " AssemblyFile="$(WixTasksPath)" />
177 - <UsingTask TaskName="ResolveWixReferences" Condition=" '$(WixTasksPath64)' != '' " AssemblyFile="$(WixTasksPath)" Architecture="x86" />
178 - <UsingTask TaskName="ResolveWixReferences" Condition=" '$(WixTasksPath64)' != '' " AssemblyFile="$(WixTasksPath64)" Architecture="x64" />
179 -
180 - <UsingTask TaskName="WindowsInstallerValidation" Condition=" '$(WixTasksPath64)' == '' " AssemblyFile="$(WixTasksPath)" />
181 - <UsingTask TaskName="WindowsInstallerValidation" Condition=" '$(WixTasksPath64)' != '' " AssemblyFile="$(WixTasksPath)" Architecture="x86" />
182 - <UsingTask TaskName="WindowsInstallerValidation" Condition=" '$(WixTasksPath64)' != '' " AssemblyFile="$(WixTasksPath64)" Architecture="x64" />
148 + <UsingTask TaskName="CreateItemAvoidingInference" AssemblyFile="$(WixTasksPath)" />
149 + <UsingTask TaskName="UpdateProjectReferenceMetadata" AssemblyFile="$(WixTasksPath)" />
150 + <UsingTask TaskName="CreateProjectReferenceDefineConstantsAndBindPaths" AssemblyFile="$(WixTasksPath)" />
151 + <UsingTask TaskName="WixAssignCulture" AssemblyFile="$(WixTasksPath)" />
152 + <UsingTask TaskName="ReadTracking" AssemblyFile="$(WixTasksPath)" />
153 + <UsingTask TaskName="ResolveWixReferences" AssemblyFile="$(WixTasksPath)" />
154 + <UsingTask TaskName="WixBuild" AssemblyFile="$(WixTasksPath)" />
155 + <UsingTask TaskName="WindowsInstallerValidation" AssemblyFile="$(WixTasksPath)" />
156
157 <!--
158 ***********************************************************************************************
@@ -661,7 +634,6 @@
634 TreatSpecificWarningsAsErrors="$(TreatSpecificWarningsAsErrors)"
635 VerboseOutput="$(VerboseOutput)"
636
664 - RunAsSeparateProcess="$(RunWixToolsOutOfProc)"
637 ToolExe="$(WixToolExe)"
638 ToolPath="$(WixToolDir)"
639 YieldDuringToolExecution="true">
src/wix/publish_t.proj
+30 -7
@@ -1,14 +1,37 @@
1 <Project Sdk="Microsoft.Build.Traversal">
2 + <PropertyGroup>
3 + <StagePublishX86>$(BaseIntermediateOutputPath)$(Configuration)\net472\x86\</StagePublishX86>
4 + <StagePublishX64>$(BaseIntermediateOutputPath)$(Configuration)\net472\x64\</StagePublishX64>
5 + <StagePublishDnc>$(BaseIntermediateOutputPath)$(Configuration)\net6.0\</StagePublishDnc>
6 +
7 + <PublishBuildFolder>$(PublishRoot)WixToolset.Sdk\build\</PublishBuildFolder>
8 + <PublishHere>$(PublishRoot)WixToolset.Sdk\tools\net472\</PublishHere>
9 + <PublishX86>$(PublishRoot)WixToolset.Sdk\tools\net472\x86\</PublishX86>
10 + <PublishX64>$(PublishRoot)WixToolset.Sdk\tools\net472\x64\</PublishX64>
11 + <PublishDnc>$(PublishRoot)WixToolset.Sdk\tools\net6.0\</PublishDnc>
12 + </PropertyGroup>
13 +
14 <ItemGroup>
15 + <ProjectReference Include="WixToolset.BuildTasks\WixToolset.BuildTasks.csproj" Properties="TargetFramework=net472;PublishDir=$(StagePublishX86)WixToolset.BuildTasks" Targets="Publish" />
16 + <ProjectReference Include="WixToolset.BuildTasks\WixToolset.BuildTasks.csproj" Properties="TargetFramework=net6.0;UseAppHost=false;PublishDir=$(StagePublishDnc)WixToolset.BuildTasks" Targets="Publish" />
17 +
18 <ProjectReference Include="wix\wix.csproj" Properties="TargetFramework=net6.0;PublishDir=$(BaseOutputPath)$(Configuration)\publish\wix\" Targets="Publish" />
19
5 - <ProjectReference Include="WixToolset.BuildTasks\WixToolset.BuildTasks.csproj" Properties="TargetFramework=net472;RuntimeIdentifier=win-x86;PublishDir=$(BaseIntermediateOutputPath)$(Configuration)\WixToolset.Sdk\separate\net472\x86\buildtasks\" Targets="Publish" />
6 - <ProjectReference Include="wix\wix.csproj" Properties="TargetFramework=net472;RuntimeIdentifier=win-x86;PublishDir=$(BaseIntermediateOutputPath)$(Configuration)\WixToolset.Sdk\separate\net472\x86\wix\" Targets="Publish" />
20 + <!-- wix.exe doesn't need to filter any files so publish it straight into its final location -->
21 + <ProjectReference Include="wix\wix.csproj" Properties="TargetFramework=net472;RuntimeIdentifier=win-x86;PublishDir=$(PublishX86)" Targets="Publish" />
22 + <ProjectReference Include="wix\wix.csproj" Properties="TargetFramework=net472;RuntimeIdentifier=win-x64;PublishDir=$(PublishX64)" Targets="Publish" />
23 + <ProjectReference Include="wix\wix.csproj" Properties="TargetFramework=net6.0;UseAppHost=false;PublishDir=$(PublishDnc)" Targets="Publish" />
24 + </ItemGroup>
25
8 - <ProjectReference Include="WixToolset.BuildTasks\WixToolset.BuildTasks.csproj" Properties="TargetFramework=net472;RuntimeIdentifier=win-x64;PublishDir=$(BaseIntermediateOutputPath)$(Configuration)\WixToolset.Sdk\separate\net472\x64\buildtasks\" Targets="Publish" />
9 - <ProjectReference Include="wix\wix.csproj" Properties="TargetFramework=net472;RuntimeIdentifier=win-x64;PublishDir=$(BaseIntermediateOutputPath)$(Configuration)\WixToolset.Sdk\separate\net472\x64\wix\" Targets="Publish" />
26 + <Target Name="CopyToFinalPublishFolder" AfterTargets="Build">
27 + <ItemGroup>
28 + <From Include="$(StagePublishX86)\WixToolset.BuildTasks\*.*" Exclude="$(StagePublishx86)\WixToolset.BuildTasks\Microsoft.Build.*.dll" To="$(PublishHere)" />
29 + <From Include="$(StagePublishDnc)\WixToolset.BuildTasks\*.*" Exclude="$(StagePublishDnc)\WixToolset.BuildTasks\Microsoft.Build.*.dll" To="$(PublishDnc)" />
30 + </ItemGroup>
31
11 - <ProjectReference Include="WixToolset.BuildTasks\WixToolset.BuildTasks.csproj" Properties="TargetFramework=net6.0;UseAppHost=false;PublishDir=$(BaseIntermediateOutputPath)$(Configuration)\WixToolset.Sdk\separate\net6.0\buildtasks\" Targets="Publish" />
12 - <ProjectReference Include="wix\wix.csproj" Properties="TargetFramework=net6.0;UseAppHost=false;PublishDir=$(BaseIntermediateOutputPath)$(Configuration)\WixToolset.Sdk\separate\net6.0\wix\" Targets="Publish" />
13 - </ItemGroup>
32 + <Copy SourceFiles="@(From)"
33 + DestinationFiles="%(To)%(RecursiveDir)%(Filename)%(Extension)"
34 + SkipUnchangedFiles="true"
35 + UseHardlinksIfPossible="true" />
36 + </Target>
37 </Project>
src/wix/test/WixToolsetTest.BuildTasks/WixBuildTaskFixture.cs
+15 -6
@@ -2,8 +2,10 @@
2
3 namespace WixToolsetTest.BuildTasks
4 {
5 + using System;
6 using System.IO;
7 using System.Linq;
8 + using System.Runtime.InteropServices;
9 using Microsoft.Build.Utilities;
10 using WixBuildTools.TestSupport;
11 using WixToolset.BuildTasks;
@@ -13,16 +15,22 @@ namespace WixToolsetTest.BuildTasks
15
16 public class WixBuildTaskFixture
17 {
18 + public static readonly string PublishedWixSdkToolsFolder = Path.Combine(Path.GetDirectoryName(new Uri(typeof(WixBuildTaskFixture).Assembly.CodeBase).AbsolutePath), "..", "..", "..", "publish", "WixToolset.Sdk", "tools");
19 +
20 + // This line replicates what happens in WixBuild task when hosted in the PublishedWixSdkToolsFolder. However, WixBuild task is hosted inproc to this test assembly so the
21 + // root folder is relative to the test assembly's folder which does not have wix.exe local. So, we have to find wix.exe relative to PublishedWixSdkToolsFolder.
22 + public static readonly string PublishedWixExeFolder = Path.Combine(PublishedWixSdkToolsFolder, "net472", RuntimeInformation.ProcessArchitecture.ToString().ToLowerInvariant());
23 +
24 [Fact]
25 public void CanBuildSimpleMsiPackage()
26 {
19 - var folder = TestData.Get(@"TestData\SimpleMsiPackage\MsiPackage");
27 + var folder = TestData.Get("TestData", "SimpleMsiPackage", "MsiPackage");
28
29 using (var fs = new DisposableFileSystem())
30 {
31 var baseFolder = fs.GetFolder();
32 var intermediateFolder = Path.Combine(baseFolder, "obj");
25 - var pdbPath = Path.Combine(baseFolder, @"bin\testpackage.wixpdb");
33 + var pdbPath = Path.Combine(baseFolder, "bin", "testpackage.wixpdb");
34 var engine = new FakeBuildEngine();
35
36 var task = new WixBuild
@@ -42,24 +50,25 @@ namespace WixToolsetTest.BuildTasks
50 new TaskItem(Path.Combine(folder, "data")),
51 },
52 IntermediateDirectory = new TaskItem(intermediateFolder),
45 - OutputFile = new TaskItem(Path.Combine(baseFolder, @"bin\test.msi")),
53 + OutputFile = new TaskItem(Path.Combine(baseFolder, "bin", "test.msi")),
54 PdbType = "Full",
55 PdbFile = new TaskItem(pdbPath),
56 DefaultCompressionLevel = "nOnE",
57 + ToolPath = PublishedWixExeFolder
58 };
59
60 var result = task.Execute();
61 Assert.True(result, $"MSBuild task failed unexpectedly. Output:\r\n{engine.Output}");
62
54 - Assert.True(File.Exists(Path.Combine(baseFolder, @"bin\test.msi")));
63 + Assert.True(File.Exists(Path.Combine(baseFolder, "bin", "test.msi")));
64 Assert.True(File.Exists(pdbPath));
56 - Assert.True(File.Exists(Path.Combine(baseFolder, @"bin\cab1.cab")));
65 + Assert.True(File.Exists(Path.Combine(baseFolder, "bin", "cab1.cab")));
66
67 var intermediate = Intermediate.Load(pdbPath);
68 var section = intermediate.Sections.Single();
69
70 var fileSymbol = section.Symbols.OfType<FileSymbol>().Single();
62 - WixAssert.StringEqual(Path.Combine(folder, @"data\test.txt"), fileSymbol[FileSymbolFields.Source].AsPath().Path);
71 + WixAssert.StringEqual(Path.Combine(folder, "data", "test.txt"), fileSymbol[FileSymbolFields.Source].AsPath().Path);
72 WixAssert.StringEqual(@"test.txt", fileSymbol[FileSymbolFields.Source].PreviousValue.AsPath().Path);
73 }
74 }
src/wix/test/WixToolsetTest.BuildTasks/WixToolsetTest.BuildTasks.csproj
+1 -2
@@ -4,7 +4,6 @@
4 <Project Sdk="Microsoft.NET.Sdk">
5 <PropertyGroup>
6 <TargetFramework>net472</TargetFramework>
7 - <RuntimeIdentifier>win-x64</RuntimeIdentifier>
7 <RequiresNativeWixAssets>true</RequiresNativeWixAssets>
8 <IsWixTestProject>true</IsWixTestProject>
9 </PropertyGroup>
@@ -18,11 +17,11 @@
17
18 <ItemGroup>
19 <ProjectReference Include="..\..\WixToolset.BuildTasks\WixToolset.BuildTasks.csproj" />
21 - <ProjectReference Include="..\..\WixToolset.Core.TestPackage\WixToolset.Core.TestPackage.csproj" />
20 </ItemGroup>
21
22 <ItemGroup>
23 <PackageReference Include="Microsoft.Build.Tasks.Core" />
24 + <PackageReference Include="WixToolset.Data" />
25 <PackageReference Include="WixBuildTools.TestSupport" />
26 </ItemGroup>
27 </Project>
src/wix/test/WixToolsetTest.Sdk/MsbuildFixture.cs
+19 -28
@@ -20,7 +20,7 @@ namespace WixToolsetTest.Sdk
20 [InlineData(BuildSystem.MSBuild64)]
21 public void CanBuildSimpleBundle(BuildSystem buildSystem)
22 {
23 - var sourceFolder = TestData.Get(@"TestData\SimpleMsiPackage");
23 + var sourceFolder = TestData.Get(@"TestData", "SimpleMsiPackage");
24
25 using (var fs = new TestDataFolderFileSystem())
26 {
@@ -430,13 +430,10 @@ namespace WixToolsetTest.Sdk
430 }
431
432 [Theory]
433 - [InlineData(BuildSystem.DotNetCoreSdk, null)]
434 - [InlineData(BuildSystem.DotNetCoreSdk, true)]
435 - [InlineData(BuildSystem.MSBuild, null)]
436 - [InlineData(BuildSystem.MSBuild, true)]
437 - [InlineData(BuildSystem.MSBuild64, null)]
438 - [InlineData(BuildSystem.MSBuild64, true)]
439 - public void CanBuildSimpleMsiPackageAsWixipl(BuildSystem buildSystem, bool? outOfProc)
433 + [InlineData(BuildSystem.DotNetCoreSdk)]
434 + [InlineData(BuildSystem.MSBuild)]
435 + [InlineData(BuildSystem.MSBuild64)]
436 + public void CanBuildSimpleMsiPackageAsWixipl(BuildSystem buildSystem)
437 {
438 var sourceFolder = TestData.Get(@"TestData\SimpleMsiPackage\MsiPackage");
439
@@ -451,10 +448,10 @@ namespace WixToolsetTest.Sdk
448 {
449 MsbuildUtilities.GetQuotedPropertySwitch(buildSystem, "WixMSBuildProps", MsbuildFixture.WixPropsPath),
450 "-p:OutputType=IntermediatePostLink",
454 - }, outOfProc: outOfProc);
451 + });
452 result.AssertSuccess();
453
457 - var wixBuildCommands = MsbuildUtilities.GetToolCommandLines(result, "wix", "build", buildSystem, outOfProc);
454 + var wixBuildCommands = MsbuildUtilities.GetToolCommandLines(result, "wix", "build", buildSystem);
455 Assert.Single(wixBuildCommands);
456
457 var path = Directory.EnumerateFiles(binFolder, @"*.*", SearchOption.AllDirectories)
@@ -465,13 +462,10 @@ namespace WixToolsetTest.Sdk
462 }
463
464 [Theory]
468 - [InlineData(BuildSystem.DotNetCoreSdk, null)]
469 - [InlineData(BuildSystem.DotNetCoreSdk, true)]
470 - [InlineData(BuildSystem.MSBuild, null)]
471 - [InlineData(BuildSystem.MSBuild, true)]
472 - [InlineData(BuildSystem.MSBuild64, null)]
473 - [InlineData(BuildSystem.MSBuild64, true)]
474 - public void CanBuildSimpleWixlib(BuildSystem buildSystem, bool? outOfProc)
465 + [InlineData(BuildSystem.DotNetCoreSdk)]
466 + [InlineData(BuildSystem.MSBuild)]
467 + [InlineData(BuildSystem.MSBuild64)]
468 + public void CanBuildSimpleWixlib(BuildSystem buildSystem)
469 {
470 var sourceFolder = TestData.Get(@"TestData", "Wixlib", "SimpleWixlib");
471
@@ -485,10 +479,10 @@ namespace WixToolsetTest.Sdk
479 var result = MsbuildUtilities.BuildProject(buildSystem, projectPath, new[]
480 {
481 MsbuildUtilities.GetQuotedPropertySwitch(buildSystem, "WixMSBuildProps", MsbuildFixture.WixPropsPath),
488 - }, outOfProc: outOfProc);
482 + });
483 result.AssertSuccess();
484
491 - var wixBuildCommands = MsbuildUtilities.GetToolCommandLines(result, "wix", "build", buildSystem, outOfProc);
485 + var wixBuildCommands = MsbuildUtilities.GetToolCommandLines(result, "wix", "build", buildSystem);
486 Assert.Single(wixBuildCommands);
487
488 var path = Directory.EnumerateFiles(binFolder, @"*.*", SearchOption.AllDirectories)
@@ -499,13 +493,10 @@ namespace WixToolsetTest.Sdk
493 }
494
495 [Theory]
502 - [InlineData(BuildSystem.DotNetCoreSdk, null)]
503 - [InlineData(BuildSystem.DotNetCoreSdk, true)]
504 - [InlineData(BuildSystem.MSBuild, null)]
505 - [InlineData(BuildSystem.MSBuild, true)]
506 - [InlineData(BuildSystem.MSBuild64, null)]
507 - [InlineData(BuildSystem.MSBuild64, true)]
508 - public void CanBuildPackageIncludingSimpleWixlib(BuildSystem buildSystem, bool? outOfProc)
496 + [InlineData(BuildSystem.DotNetCoreSdk)]
497 + [InlineData(BuildSystem.MSBuild)]
498 + [InlineData(BuildSystem.MSBuild64)]
499 + public void CanBuildPackageIncludingSimpleWixlib(BuildSystem buildSystem)
500 {
501 var sourceFolder = TestData.Get(@"TestData", "Wixlib");
502
@@ -519,7 +510,7 @@ namespace WixToolsetTest.Sdk
510 var result = MsbuildUtilities.BuildProject(buildSystem, projectPath, new[]
511 {
512 MsbuildUtilities.GetQuotedPropertySwitch(buildSystem, "WixMSBuildProps", MsbuildFixture.WixPropsPath),
522 - }, outOfProc: outOfProc);
513 + });
514 result.AssertSuccess();
515
516 var paths = Directory.EnumerateFiles(binFolder, @"*.*", SearchOption.AllDirectories)
@@ -612,7 +603,7 @@ namespace WixToolsetTest.Sdk
603 var result = MsbuildUtilities.BuildProject(buildSystem, projectPath, new[]
604 {
605 MsbuildUtilities.GetQuotedPropertySwitch(buildSystem, "WixToolDir", Path.Combine(MsbuildFixture.WixMsbuildPath, "broken", "net461")),
615 - }, outOfProc: true);
606 + });
607 Assert.Equal(1, result.ExitCode);
608
609 var expectedMessage = "System.PlatformNotSupportedException: Could not find platform specific 'wixnative.exe' ---> System.IO.FileNotFoundException: Could not find internal piece of WiX Toolset from";
src/wix/wix.cmd
+38 -26
@@ -3,14 +3,19 @@
3
4 @set _C=Debug
5 @set _L=%~dp0..\..\build\logs
6 +
7 :parse_args
8 @if /i "%1"=="release" set _C=Release
9 +@if /i "%1"=="inc" set _INC=1
10 +@if /i "%1"=="clean" set _CLEAN=1
11 @if not "%1"=="" shift & goto parse_args
12
13 @set _B=%~dp0..\..\build\wix\%_C%
11 -@set _P_OBJ=%~dp0..\..\build\wix\obj\publish_t\%_C%\
12 -@set _P=%~dp0..\..\build\wix\%_C%\publish\
13 -@set _RCO=/S /R:1 /W:1 /NP /XO /NS /NC /NFL /NDL /NJH /NJS
14 +
15 +:: Clean
16 +
17 +@if "%_INC%"=="" call :clean
18 +@if NOT "%_CLEAN%"=="" goto :end
19
20 @echo Building wix %_C%
21
@@ -23,29 +28,8 @@ msbuild wixnative\wixnative_t.proj -p:Configuration=%_C% -nologo -m -warnaserror
28
29 msbuild wix.sln -p:Configuration=%_C% -nologo -m -warnaserror -bl:%_L%\wix_build.binlog || exit /b
30
26 -
27 -:: Pre-Publish Test
28 -dotnet test ^
29 - %_B%\test\WixToolsetTest.Converters\net6.0\WixToolsetTest.Converters.dll ^
30 - %_B%\test\WixToolsetTest.Converters.Symbolizer\net472\WixToolsetTest.Converters.Symbolizer.dll ^
31 - %_B%\test\WixToolsetTest.Core\net6.0\WixToolsetTest.Core.dll ^
32 - %_B%\test\WixToolsetTest.Core.Native\net6.0\win-x64\WixToolsetTest.Core.Native.dll ^
33 - %_B%\test\WixToolsetTest.CoreIntegration\net6.0\WixToolsetTest.CoreIntegration.dll ^
34 - --nologo -l "trx;LogFileName=%_L%\TestResults\wix_prepublish.trx" || exit /b
35 -
36 -
37 -:: Publish
31 msbuild publish_t.proj -p:Configuration=%_C% -nologo -warnaserror -bl:%_L%\wix_publish.binlog || exit /b
32
40 -robocopy %_P_OBJ%\WixToolset.Sdk\separate\net472\x86\buildtasks %_P%\WixToolset.Sdk\tools\net472\x86 %_RCO% /XF Microsoft.Build.*.dll
41 -robocopy %_P_OBJ%\WixToolset.Sdk\separate\net472\x86\wix %_P%\WixToolset.Sdk\tools\net472\x86 %_RCO%
42 -
43 -robocopy %_P_OBJ%\WixToolset.Sdk\separate\net472\x64\buildtasks %_P%\WixToolset.Sdk\tools\net472\x64 %_RCO% /XF Microsoft.Build.*.dll
44 -robocopy %_P_OBJ%\WixToolset.Sdk\separate\net472\x64\wix %_P%\WixToolset.Sdk\tools\net472\x64 %_RCO%
45 -
46 -robocopy %_P_OBJ%\WixToolset.Sdk\separate\net6.0\buildtasks %_P%\WixToolset.Sdk\tools\net6.0 %_RCO% /XF Microsoft.Build.*.dll
47 -robocopy %_P_OBJ%\WixToolset.Sdk\separate\net6.0\wix %_P%\WixToolset.Sdk\tools\net6.0 %_RCO%
48 -
33 msbuild -t:Publish -p:Configuration=%_C% -nologo -warnaserror WixToolset.Sdk\WixToolset.Sdk.csproj -bl:%_L%\wix_sdk_publish.binlog || exit /b
34
35 :: TODO - used by MsbuildFixture.ReportsInnerExceptionForUnexpectedExceptions test
@@ -54,13 +38,41 @@ msbuild -t:Publish -p:Configuration=%_C% -nologo -warnaserror WixToolset.Sdk\Wix
38
39 :: Test
40 dotnet test ^
57 - %_B%\test\WixToolsetTest.BuildTasks\net472\win-x64\WixToolsetTest.BuildTasks.dll ^
41 + %_B%\test\WixToolsetTest.Converters\net6.0\WixToolsetTest.Converters.dll ^
42 + %_B%\test\WixToolsetTest.Converters.Symbolizer\net472\WixToolsetTest.Converters.Symbolizer.dll ^
43 + %_B%\test\WixToolsetTest.Core\net6.0\WixToolsetTest.Core.dll ^
44 + %_B%\test\WixToolsetTest.Core.Native\net6.0\win-x64\WixToolsetTest.Core.Native.dll ^
45 + %_B%\test\WixToolsetTest.CoreIntegration\net6.0\WixToolsetTest.CoreIntegration.dll ^
46 + %_B%\test\WixToolsetTest.BuildTasks\net472\WixToolsetTest.BuildTasks.dll ^
47 %_B%\test\WixToolsetTest.Sdk\net472\WixToolsetTest.Sdk.dll ^
59 - --nologo -l "trx;LogFileName=%_L%\TestResults\wix_postpublish.trx" || exit /b
48 + --nologo -l "trx;LogFileName=%_L%\TestResults\wix.trx" || exit /b
49
50
51 :: Pack
52 msbuild pack_t.proj -p:Configuration=%_C% -nologo -m -warnaserror -bl:%_L%\wix_pack.binlog || exit /b
53
54 +@goto :end
55 +
56 +:clean
57 +@rd /s/q "..\..\build\wix" 2> nul
58 +@del "..\..\build\artifacts\wix.*.nupkg" 2> nul
59 +@del "..\..\build\artifacts\WixToolset.BuildTasks.*.nupkg" 2> nul
60 +@del "..\..\build\artifacts\WixToolset.Converters.*.nupkg" 2> nul
61 +@del "..\..\build\artifacts\WixToolset.Core.*.nupkg" 2> nul
62 +@del "..\..\build\artifacts\WixToolset.Sdk.*.nupkg" 2> nul
63 +@del "%_L%\TestResults\wix.trx" 2> nul
64 +@rd /s/q "%USERPROFILE%\.nuget\packages\wix" 2> nul
65 +@rd /s/q "%USERPROFILE%\.nuget\packages\wixtoolset.buildtasks" 2> nul
66 +@rd /s/q "%USERPROFILE%\.nuget\packages\wixtoolset.converters" 2> nul
67 +@rd /s/q "%USERPROFILE%\.nuget\packages\wixtoolset.converters.symbolizer" 2> nul
68 +@rd /s/q "%USERPROFILE%\.nuget\packages\wixtoolset.core" 2> nul
69 +@rd /s/q "%USERPROFILE%\.nuget\packages\wixtoolset.core.burn" 2> nul
70 +@rd /s/q "%USERPROFILE%\.nuget\packages\wixtoolset.core.native" 2> nul
71 +@rd /s/q "%USERPROFILE%\.nuget\packages\wixtoolset.core.windowsinstaller" 2> nul
72 +@rd /s/q "%USERPROFILE%\.nuget\packages\wixtoolset.core.testpackage" 2> nul
73 +@rd /s/q "%USERPROFILE%\.nuget\packages\wixtoolset.sdk" 2> nul
74 +@exit /b
75 +
76 +:end
77 @popd
78 @endlocal