diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/WixToolset.BuildTasks/HeatTask_InProc.cs | 2 | ||||
| -rw-r--r-- | src/WixToolset.BuildTasks/MsbuildMessageListener.cs | 2 | ||||
| -rw-r--r-- | src/WixToolset.BuildTasks/ToolsetTask.cs | 49 | ||||
| -rw-r--r-- | src/WixToolset.BuildTasks/ToolsetTask_InProc.cs | 2 | ||||
| -rw-r--r-- | src/WixToolset.BuildTasks/WixBuild_InProc.cs | 2 | ||||
| -rw-r--r-- | src/WixToolset.BuildTasks/WixToolset.BuildTasks.csproj | 11 | ||||
| -rw-r--r-- | src/test/WixToolsetTest.MSBuild/MsbuildFixture.cs | 30 | ||||
| -rw-r--r-- | src/test/WixToolsetTest.MSBuild/MsbuildHeatFixture.cs | 11 | ||||
| -rw-r--r-- | src/test/WixToolsetTest.MSBuild/MsbuildUtilities.cs | 46 |
9 files changed, 126 insertions, 29 deletions
diff --git a/src/WixToolset.BuildTasks/HeatTask_InProc.cs b/src/WixToolset.BuildTasks/HeatTask_InProc.cs index 8190d9e2..eb6feafc 100644 --- a/src/WixToolset.BuildTasks/HeatTask_InProc.cs +++ b/src/WixToolset.BuildTasks/HeatTask_InProc.cs | |||
| @@ -1,5 +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. | 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 | 2 | ||
| 3 | #if !NETCOREAPP | ||
| 3 | namespace WixToolset.BuildTasks | 4 | namespace WixToolset.BuildTasks |
| 4 | { | 5 | { |
| 5 | using WixToolset.Extensibility; | 6 | using WixToolset.Extensibility; |
| @@ -25,3 +26,4 @@ namespace WixToolset.BuildTasks | |||
| 25 | } | 26 | } |
| 26 | } | 27 | } |
| 27 | } | 28 | } |
| 29 | #endif | ||
diff --git a/src/WixToolset.BuildTasks/MsbuildMessageListener.cs b/src/WixToolset.BuildTasks/MsbuildMessageListener.cs index 47399a41..f186d721 100644 --- a/src/WixToolset.BuildTasks/MsbuildMessageListener.cs +++ b/src/WixToolset.BuildTasks/MsbuildMessageListener.cs | |||
| @@ -1,5 +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. | 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 | 2 | ||
| 3 | #if !NETCOREAPP | ||
| 3 | namespace WixToolset.BuildTasks | 4 | namespace WixToolset.BuildTasks |
| 4 | { | 5 | { |
| 5 | using System; | 6 | using System; |
| @@ -64,3 +65,4 @@ namespace WixToolset.BuildTasks | |||
| 64 | public MessageLevel CalculateMessageLevel(IMessaging messaging, Message message, MessageLevel defaultMessageLevel) => defaultMessageLevel; | 65 | public MessageLevel CalculateMessageLevel(IMessaging messaging, Message message, MessageLevel defaultMessageLevel) => defaultMessageLevel; |
| 65 | } | 66 | } |
| 66 | } | 67 | } |
| 68 | #endif | ||
diff --git a/src/WixToolset.BuildTasks/ToolsetTask.cs b/src/WixToolset.BuildTasks/ToolsetTask.cs index 4fd7af3f..94d007f0 100644 --- a/src/WixToolset.BuildTasks/ToolsetTask.cs +++ b/src/WixToolset.BuildTasks/ToolsetTask.cs | |||
| @@ -4,10 +4,13 @@ namespace WixToolset.BuildTasks | |||
| 4 | { | 4 | { |
| 5 | using System; | 5 | using System; |
| 6 | using System.IO; | 6 | using System.IO; |
| 7 | using System.Runtime.InteropServices; | ||
| 7 | using Microsoft.Build.Utilities; | 8 | using Microsoft.Build.Utilities; |
| 8 | 9 | ||
| 9 | public abstract partial class ToolsetTask : ToolTask | 10 | public abstract partial class ToolsetTask : ToolTask |
| 10 | { | 11 | { |
| 12 | private static readonly string ThisDllPath = new Uri(typeof(ToolsetTask).Assembly.CodeBase).AbsolutePath; | ||
| 13 | |||
| 11 | /// <summary> | 14 | /// <summary> |
| 12 | /// Gets or sets additional options that are appended the the tool command-line. | 15 | /// Gets or sets additional options that are appended the the tool command-line. |
| 13 | /// </summary> | 16 | /// </summary> |
| @@ -53,6 +56,8 @@ namespace WixToolset.BuildTasks | |||
| 53 | /// </summary> | 56 | /// </summary> |
| 54 | public bool VerboseOutput { get; set; } | 57 | public bool VerboseOutput { get; set; } |
| 55 | 58 | ||
| 59 | private string ToolFullPath => Path.Combine(Path.GetDirectoryName(ThisDllPath), this.ToolExe); | ||
| 60 | |||
| 56 | /// <summary> | 61 | /// <summary> |
| 57 | /// Get the path to the executable. | 62 | /// Get the path to the executable. |
| 58 | /// </summary> | 63 | /// </summary> |
| @@ -63,13 +68,20 @@ namespace WixToolset.BuildTasks | |||
| 63 | /// </remarks> | 68 | /// </remarks> |
| 64 | protected sealed override string GenerateFullPathToTool() | 69 | protected sealed override string GenerateFullPathToTool() |
| 65 | { | 70 | { |
| 66 | var thisDllPath = new Uri(typeof(ToolsetTask).Assembly.CodeBase).AbsolutePath; | 71 | #if !NETCOREAPP |
| 67 | if (!this.RunAsSeparateProcess) | 72 | if (!this.RunAsSeparateProcess) |
| 68 | { | 73 | { |
| 69 | // 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. | 74 | // 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. |
| 70 | return thisDllPath; | 75 | return ThisDllPath; |
| 71 | } | 76 | } |
| 72 | return Path.Combine(Path.GetDirectoryName(thisDllPath), this.ToolExe); | 77 | return this.ToolFullPath; |
| 78 | #else | ||
| 79 | if (IsSelfExecutable(this.ToolFullPath, out var toolFullPath)) | ||
| 80 | { | ||
| 81 | return toolFullPath; | ||
| 82 | } | ||
| 83 | return DotnetFullPath; | ||
| 84 | #endif | ||
| 73 | } | 85 | } |
| 74 | 86 | ||
| 75 | protected sealed override string GenerateResponseFileCommands() | 87 | protected sealed override string GenerateResponseFileCommands() |
| @@ -94,5 +106,36 @@ namespace WixToolset.BuildTasks | |||
| 94 | commandLineBuilder.AppendArrayIfNotNull("-wx ", this.TreatSpecificWarningsAsErrors); | 106 | commandLineBuilder.AppendArrayIfNotNull("-wx ", this.TreatSpecificWarningsAsErrors); |
| 95 | commandLineBuilder.AppendIfTrue("-wx", this.TreatWarningsAsErrors); | 107 | commandLineBuilder.AppendIfTrue("-wx", this.TreatWarningsAsErrors); |
| 96 | } | 108 | } |
| 109 | |||
| 110 | #if NETCOREAPP | ||
| 111 | private static readonly string DotnetFullPath = Environment.GetEnvironmentVariable("DOTNET_HOST_PATH") ?? "dotnet"; | ||
| 112 | |||
| 113 | protected override string GenerateCommandLineCommands() | ||
| 114 | { | ||
| 115 | if (IsSelfExecutable(this.ToolFullPath, out var toolFullPath)) | ||
| 116 | { | ||
| 117 | return null; | ||
| 118 | } | ||
| 119 | else | ||
| 120 | { | ||
| 121 | return $"exec \"{toolFullPath}\""; | ||
| 122 | } | ||
| 123 | } | ||
| 124 | |||
| 125 | private static bool IsSelfExecutable(string proposedToolFullPath, out string toolFullPath) | ||
| 126 | { | ||
| 127 | var toolFullPathWithoutExtension = Path.Combine(Path.GetDirectoryName(proposedToolFullPath), Path.GetFileNameWithoutExtension(proposedToolFullPath)); | ||
| 128 | var exeExtension = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ".exe" : String.Empty; | ||
| 129 | var exeToolFullPath = $"{toolFullPathWithoutExtension}{exeExtension}"; | ||
| 130 | if (File.Exists(exeToolFullPath)) | ||
| 131 | { | ||
| 132 | toolFullPath = exeToolFullPath; | ||
| 133 | return true; | ||
| 134 | } | ||
| 135 | |||
| 136 | toolFullPath = $"{toolFullPathWithoutExtension}.dll"; | ||
| 137 | return false; | ||
| 138 | } | ||
| 139 | #endif | ||
| 97 | } | 140 | } |
| 98 | } | 141 | } |
diff --git a/src/WixToolset.BuildTasks/ToolsetTask_InProc.cs b/src/WixToolset.BuildTasks/ToolsetTask_InProc.cs index 4b365b2a..a3290e60 100644 --- a/src/WixToolset.BuildTasks/ToolsetTask_InProc.cs +++ b/src/WixToolset.BuildTasks/ToolsetTask_InProc.cs | |||
| @@ -1,5 +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. | 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 | 2 | ||
| 3 | #if !NETCOREAPP | ||
| 3 | namespace WixToolset.BuildTasks | 4 | namespace WixToolset.BuildTasks |
| 4 | { | 5 | { |
| 5 | using System; | 6 | using System; |
| @@ -69,3 +70,4 @@ namespace WixToolset.BuildTasks | |||
| 69 | protected abstract string TaskShortName { get; } | 70 | protected abstract string TaskShortName { get; } |
| 70 | } | 71 | } |
| 71 | } | 72 | } |
| 73 | #endif | ||
diff --git a/src/WixToolset.BuildTasks/WixBuild_InProc.cs b/src/WixToolset.BuildTasks/WixBuild_InProc.cs index 8e9f2fec..49148c8a 100644 --- a/src/WixToolset.BuildTasks/WixBuild_InProc.cs +++ b/src/WixToolset.BuildTasks/WixBuild_InProc.cs | |||
| @@ -1,5 +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. | 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 | 2 | ||
| 3 | #if !NETCOREAPP | ||
| 3 | namespace WixToolset.BuildTasks | 4 | namespace WixToolset.BuildTasks |
| 4 | { | 5 | { |
| 5 | using WixToolset.Data; | 6 | using WixToolset.Data; |
| @@ -51,3 +52,4 @@ namespace WixToolset.BuildTasks | |||
| 51 | } | 52 | } |
| 52 | } | 53 | } |
| 53 | } | 54 | } |
| 55 | #endif | ||
diff --git a/src/WixToolset.BuildTasks/WixToolset.BuildTasks.csproj b/src/WixToolset.BuildTasks/WixToolset.BuildTasks.csproj index 221478ed..6709949e 100644 --- a/src/WixToolset.BuildTasks/WixToolset.BuildTasks.csproj +++ b/src/WixToolset.BuildTasks/WixToolset.BuildTasks.csproj | |||
| @@ -18,19 +18,18 @@ | |||
| 18 | </PropertyGroup> | 18 | </PropertyGroup> |
| 19 | 19 | ||
| 20 | <ItemGroup> | 20 | <ItemGroup> |
| 21 | <ProjectReference Include="..\WixToolset.Tools.Core\WixToolset.Tools.Core.csproj" /> | 21 | <PackageReference Include="WixToolset.Dtf.WindowsInstaller" Version="4.0.*" /> |
| 22 | </ItemGroup> | 22 | </ItemGroup> |
| 23 | 23 | ||
| 24 | <ItemGroup> | 24 | <ItemGroup Condition="'$(TargetFramework)'=='net461'"> |
| 25 | <PackageReference Include="Microsoft.Build.Tasks.Core" Version="14.3" /> | ||
| 25 | <PackageReference Include="WixToolset.Core.Burn" Version="4.0.*" /> | 26 | <PackageReference Include="WixToolset.Core.Burn" Version="4.0.*" /> |
| 26 | <PackageReference Include="WixToolset.Core.WindowsInstaller" Version="4.0.*" /> | 27 | <PackageReference Include="WixToolset.Core.WindowsInstaller" Version="4.0.*" /> |
| 27 | <PackageReference Include="WixToolset.Dtf.WindowsInstaller" Version="4.0.*" /> | ||
| 28 | <PackageReference Include="WixToolset.Harvesters" Version="4.0.*" /> | 28 | <PackageReference Include="WixToolset.Harvesters" Version="4.0.*" /> |
| 29 | </ItemGroup> | 29 | </ItemGroup> |
| 30 | 30 | ||
| 31 | <ItemGroup> | 31 | <ItemGroup Condition="'$(TargetFramework)'=='netcoreapp2.1' "> |
| 32 | <PackageReference Include="Microsoft.Build.Tasks.Core" Version="14.3" Condition="'$(TargetFramework)'=='net461'" /> | 32 | <PackageReference Include="Microsoft.Build.Tasks.Core" Version="15.7.179" /> |
| 33 | <PackageReference Include="Microsoft.Build.Tasks.Core" Version="15.7.179" Condition="'$(TargetFramework)'=='netcoreapp2.1' " /> | ||
| 34 | </ItemGroup> | 33 | </ItemGroup> |
| 35 | 34 | ||
| 36 | <ItemGroup> | 35 | <ItemGroup> |
diff --git a/src/test/WixToolsetTest.MSBuild/MsbuildFixture.cs b/src/test/WixToolsetTest.MSBuild/MsbuildFixture.cs index 6862f2a8..71255165 100644 --- a/src/test/WixToolsetTest.MSBuild/MsbuildFixture.cs +++ b/src/test/WixToolsetTest.MSBuild/MsbuildFixture.cs | |||
| @@ -12,6 +12,7 @@ namespace WixToolsetTest.MSBuild | |||
| 12 | public class MsbuildFixture | 12 | public class MsbuildFixture |
| 13 | { | 13 | { |
| 14 | [Theory] | 14 | [Theory] |
| 15 | [InlineData(BuildSystem.DotNetCoreSdk)] | ||
| 15 | [InlineData(BuildSystem.MSBuild)] | 16 | [InlineData(BuildSystem.MSBuild)] |
| 16 | [InlineData(BuildSystem.MSBuild64)] | 17 | [InlineData(BuildSystem.MSBuild64)] |
| 17 | public void CanBuildSimpleBundle(BuildSystem buildSystem) | 18 | public void CanBuildSimpleBundle(BuildSystem buildSystem) |
| @@ -44,6 +45,7 @@ namespace WixToolsetTest.MSBuild | |||
| 44 | } | 45 | } |
| 45 | 46 | ||
| 46 | [Theory] | 47 | [Theory] |
| 48 | [InlineData(BuildSystem.DotNetCoreSdk)] | ||
| 47 | [InlineData(BuildSystem.MSBuild)] | 49 | [InlineData(BuildSystem.MSBuild)] |
| 48 | [InlineData(BuildSystem.MSBuild64)] | 50 | [InlineData(BuildSystem.MSBuild64)] |
| 49 | public void CanBuildSimpleMergeModule(BuildSystem buildSystem) | 51 | public void CanBuildSimpleMergeModule(BuildSystem buildSystem) |
| @@ -76,6 +78,7 @@ namespace WixToolsetTest.MSBuild | |||
| 76 | } | 78 | } |
| 77 | 79 | ||
| 78 | [Theory] | 80 | [Theory] |
| 81 | [InlineData(BuildSystem.DotNetCoreSdk)] | ||
| 79 | [InlineData(BuildSystem.MSBuild)] | 82 | [InlineData(BuildSystem.MSBuild)] |
| 80 | [InlineData(BuildSystem.MSBuild64)] | 83 | [InlineData(BuildSystem.MSBuild64)] |
| 81 | public void CanBuildSimpleMsiPackage(BuildSystem buildSystem) | 84 | public void CanBuildSimpleMsiPackage(BuildSystem buildSystem) |
| @@ -112,6 +115,7 @@ namespace WixToolsetTest.MSBuild | |||
| 112 | } | 115 | } |
| 113 | 116 | ||
| 114 | [Theory] | 117 | [Theory] |
| 118 | [InlineData(BuildSystem.DotNetCoreSdk)] | ||
| 115 | [InlineData(BuildSystem.MSBuild)] | 119 | [InlineData(BuildSystem.MSBuild)] |
| 116 | [InlineData(BuildSystem.MSBuild64)] | 120 | [InlineData(BuildSystem.MSBuild64)] |
| 117 | public void CanBuildSimpleMsiPackageWithMergeModule(BuildSystem buildSystem) | 121 | public void CanBuildSimpleMsiPackageWithMergeModule(BuildSystem buildSystem) |
| @@ -145,6 +149,7 @@ namespace WixToolsetTest.MSBuild | |||
| 145 | } | 149 | } |
| 146 | 150 | ||
| 147 | [Theory] | 151 | [Theory] |
| 152 | [InlineData(BuildSystem.DotNetCoreSdk)] | ||
| 148 | [InlineData(BuildSystem.MSBuild)] | 153 | [InlineData(BuildSystem.MSBuild)] |
| 149 | [InlineData(BuildSystem.MSBuild64)] | 154 | [InlineData(BuildSystem.MSBuild64)] |
| 150 | public void CanBuildWithDefaultAndExplicitlyFullWixpdbs(BuildSystem buildSystem) | 155 | public void CanBuildWithDefaultAndExplicitlyFullWixpdbs(BuildSystem buildSystem) |
| @@ -161,6 +166,7 @@ namespace WixToolsetTest.MSBuild | |||
| 161 | } | 166 | } |
| 162 | 167 | ||
| 163 | [Theory] | 168 | [Theory] |
| 169 | [InlineData(BuildSystem.DotNetCoreSdk)] | ||
| 164 | [InlineData(BuildSystem.MSBuild)] | 170 | [InlineData(BuildSystem.MSBuild)] |
| 165 | [InlineData(BuildSystem.MSBuild64)] | 171 | [InlineData(BuildSystem.MSBuild64)] |
| 166 | public void CanBuildWithNoWixpdb(BuildSystem buildSystem) | 172 | public void CanBuildWithNoWixpdb(BuildSystem buildSystem) |
| @@ -198,6 +204,7 @@ namespace WixToolsetTest.MSBuild | |||
| 198 | } | 204 | } |
| 199 | 205 | ||
| 200 | [Theory] | 206 | [Theory] |
| 207 | [InlineData(BuildSystem.DotNetCoreSdk)] | ||
| 201 | [InlineData(BuildSystem.MSBuild)] | 208 | [InlineData(BuildSystem.MSBuild)] |
| 202 | [InlineData(BuildSystem.MSBuild64)] | 209 | [InlineData(BuildSystem.MSBuild64)] |
| 203 | public void CanBuild64BitMsiPackage(BuildSystem buildSystem) | 210 | public void CanBuild64BitMsiPackage(BuildSystem buildSystem) |
| @@ -234,6 +241,7 @@ namespace WixToolsetTest.MSBuild | |||
| 234 | } | 241 | } |
| 235 | 242 | ||
| 236 | [Theory(Skip = "Currently fails")] | 243 | [Theory(Skip = "Currently fails")] |
| 244 | [InlineData(BuildSystem.DotNetCoreSdk)] | ||
| 237 | [InlineData(BuildSystem.MSBuild)] | 245 | [InlineData(BuildSystem.MSBuild)] |
| 238 | [InlineData(BuildSystem.MSBuild64)] | 246 | [InlineData(BuildSystem.MSBuild64)] |
| 239 | public void CanBuildSimpleMsiPackageWithIceSuppressions(BuildSystem buildSystem) | 247 | public void CanBuildSimpleMsiPackageWithIceSuppressions(BuildSystem buildSystem) |
| @@ -249,13 +257,14 @@ namespace WixToolsetTest.MSBuild | |||
| 249 | 257 | ||
| 250 | var result = MsbuildUtilities.BuildProject(buildSystem, projectPath, new[] | 258 | var result = MsbuildUtilities.BuildProject(buildSystem, projectPath, new[] |
| 251 | { | 259 | { |
| 252 | "-p:SuppressIces=\"ICE45;ICE46\"", | 260 | MsbuildUtilities.GetQuotedPropertySwitch(buildSystem, "SuppressIces", "ICE45;ICE46"), |
| 253 | }); | 261 | }); |
| 254 | result.AssertSuccess(); | 262 | result.AssertSuccess(); |
| 255 | } | 263 | } |
| 256 | } | 264 | } |
| 257 | 265 | ||
| 258 | [Theory] | 266 | [Theory] |
| 267 | [InlineData(BuildSystem.DotNetCoreSdk)] | ||
| 259 | [InlineData(BuildSystem.MSBuild)] | 268 | [InlineData(BuildSystem.MSBuild)] |
| 260 | [InlineData(BuildSystem.MSBuild64)] | 269 | [InlineData(BuildSystem.MSBuild64)] |
| 261 | public void CanBuildSimpleMsiPackageWithWarningSuppressions(BuildSystem buildSystem) | 270 | public void CanBuildSimpleMsiPackageWithWarningSuppressions(BuildSystem buildSystem) |
| @@ -271,7 +280,7 @@ namespace WixToolsetTest.MSBuild | |||
| 271 | 280 | ||
| 272 | var result = MsbuildUtilities.BuildProject(buildSystem, projectPath, new[] | 281 | var result = MsbuildUtilities.BuildProject(buildSystem, projectPath, new[] |
| 273 | { | 282 | { |
| 274 | "-p:SuppressSpecificWarnings=\"1118;1102\"", | 283 | MsbuildUtilities.GetQuotedPropertySwitch(buildSystem, "SuppressSpecificWarnings", "1118;1102"), |
| 275 | }); | 284 | }); |
| 276 | result.AssertSuccess(); | 285 | result.AssertSuccess(); |
| 277 | 286 | ||
| @@ -281,6 +290,8 @@ namespace WixToolsetTest.MSBuild | |||
| 281 | } | 290 | } |
| 282 | 291 | ||
| 283 | [Theory] | 292 | [Theory] |
| 293 | [InlineData(BuildSystem.DotNetCoreSdk, null)] | ||
| 294 | [InlineData(BuildSystem.DotNetCoreSdk, true)] | ||
| 284 | [InlineData(BuildSystem.MSBuild, null)] | 295 | [InlineData(BuildSystem.MSBuild, null)] |
| 285 | [InlineData(BuildSystem.MSBuild, true)] | 296 | [InlineData(BuildSystem.MSBuild, true)] |
| 286 | [InlineData(BuildSystem.MSBuild64, null)] | 297 | [InlineData(BuildSystem.MSBuild64, null)] |
| @@ -302,10 +313,8 @@ namespace WixToolsetTest.MSBuild | |||
| 302 | }, outOfProc: outOfProc); | 313 | }, outOfProc: outOfProc); |
| 303 | result.AssertSuccess(); | 314 | result.AssertSuccess(); |
| 304 | 315 | ||
| 305 | var expectedOutOfProc = outOfProc.HasValue && outOfProc.Value; | 316 | var wixBuildCommands = MsbuildUtilities.GetToolCommandLines(result, "wix", "build", buildSystem, outOfProc); |
| 306 | var expectedWixCommand = $"{(expectedOutOfProc ? "wix.exe" : "(wix.exe)")} build"; | 317 | Assert.Single(wixBuildCommands); |
| 307 | var buildCommands = result.Output.Where(line => line.TrimStart().Contains(expectedWixCommand)); | ||
| 308 | Assert.Single(buildCommands); | ||
| 309 | 318 | ||
| 310 | var path = Directory.EnumerateFiles(binFolder, @"*.*", SearchOption.AllDirectories) | 319 | var path = Directory.EnumerateFiles(binFolder, @"*.*", SearchOption.AllDirectories) |
| 311 | .Select(s => s.Substring(baseFolder.Length + 1)) | 320 | .Select(s => s.Substring(baseFolder.Length + 1)) |
| @@ -315,6 +324,7 @@ namespace WixToolsetTest.MSBuild | |||
| 315 | } | 324 | } |
| 316 | 325 | ||
| 317 | [Theory] | 326 | [Theory] |
| 327 | [InlineData(BuildSystem.DotNetCoreSdk)] | ||
| 318 | [InlineData(BuildSystem.MSBuild)] | 328 | [InlineData(BuildSystem.MSBuild)] |
| 319 | [InlineData(BuildSystem.MSBuild64)] | 329 | [InlineData(BuildSystem.MSBuild64)] |
| 320 | public void CanBuildAndCleanSimpleMsiPackage(BuildSystem buildSystem) | 330 | public void CanBuildAndCleanSimpleMsiPackage(BuildSystem buildSystem) |
| @@ -328,10 +338,7 @@ namespace WixToolsetTest.MSBuild | |||
| 328 | var projectPath = Path.Combine(baseFolder, "MsiPackage.wixproj"); | 338 | var projectPath = Path.Combine(baseFolder, "MsiPackage.wixproj"); |
| 329 | 339 | ||
| 330 | // Build | 340 | // Build |
| 331 | var result = MsbuildUtilities.BuildProject(buildSystem, projectPath, new[] | 341 | var result = MsbuildUtilities.BuildProject(buildSystem, projectPath, verbosityLevel: "diag"); |
| 332 | { | ||
| 333 | "-v:diag", | ||
| 334 | }); | ||
| 335 | result.AssertSuccess(); | 342 | result.AssertSuccess(); |
| 336 | 343 | ||
| 337 | var buildOutput = String.Join("\r\n", result.Output); | 344 | var buildOutput = String.Join("\r\n", result.Output); |
| @@ -346,8 +353,7 @@ namespace WixToolsetTest.MSBuild | |||
| 346 | result = MsbuildUtilities.BuildProject(buildSystem, projectPath, new[] | 353 | result = MsbuildUtilities.BuildProject(buildSystem, projectPath, new[] |
| 347 | { | 354 | { |
| 348 | "-t:Clean", | 355 | "-t:Clean", |
| 349 | "-v:diag", | 356 | }, verbosityLevel: "diag"); |
| 350 | }); | ||
| 351 | result.AssertSuccess(); | 357 | result.AssertSuccess(); |
| 352 | 358 | ||
| 353 | var cleanOutput = String.Join("\r\n", result.Output); | 359 | var cleanOutput = String.Join("\r\n", result.Output); |
diff --git a/src/test/WixToolsetTest.MSBuild/MsbuildHeatFixture.cs b/src/test/WixToolsetTest.MSBuild/MsbuildHeatFixture.cs index b5c71f86..f5f03be0 100644 --- a/src/test/WixToolsetTest.MSBuild/MsbuildHeatFixture.cs +++ b/src/test/WixToolsetTest.MSBuild/MsbuildHeatFixture.cs | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | namespace WixToolsetTest.MSBuild | 3 | namespace WixToolsetTest.MSBuild |
| 4 | { | 4 | { |
| 5 | using System; | 5 | using System; |
| 6 | using System.Collections.Generic; | ||
| 6 | using System.IO; | 7 | using System.IO; |
| 7 | using System.Linq; | 8 | using System.Linq; |
| 8 | using WixBuildTools.TestSupport; | 9 | using WixBuildTools.TestSupport; |
| @@ -14,6 +15,7 @@ namespace WixToolsetTest.MSBuild | |||
| 14 | public class MsbuildHeatFixture | 15 | public class MsbuildHeatFixture |
| 15 | { | 16 | { |
| 16 | [Theory] | 17 | [Theory] |
| 18 | [InlineData(BuildSystem.DotNetCoreSdk)] | ||
| 17 | [InlineData(BuildSystem.MSBuild)] | 19 | [InlineData(BuildSystem.MSBuild)] |
| 18 | [InlineData(BuildSystem.MSBuild64)] | 20 | [InlineData(BuildSystem.MSBuild64)] |
| 19 | public void CanBuildHeatFilePackage(BuildSystem buildSystem) | 21 | public void CanBuildHeatFilePackage(BuildSystem buildSystem) |
| @@ -31,9 +33,7 @@ namespace WixToolsetTest.MSBuild | |||
| 31 | var result = MsbuildUtilities.BuildProject(buildSystem, projectPath); | 33 | var result = MsbuildUtilities.BuildProject(buildSystem, projectPath); |
| 32 | result.AssertSuccess(); | 34 | result.AssertSuccess(); |
| 33 | 35 | ||
| 34 | var expectedOutOfProc = false; | 36 | var heatCommandLines = MsbuildUtilities.GetToolCommandLines(result, "heat", "file", buildSystem); |
| 35 | var expectedHeatCommand = $"{(expectedOutOfProc ? "heat.exe" : "(heat.exe)")} file"; | ||
| 36 | var heatCommandLines = result.Output.Where(line => line.Contains(expectedHeatCommand)); | ||
| 37 | Assert.Single(heatCommandLines); | 37 | Assert.Single(heatCommandLines); |
| 38 | 38 | ||
| 39 | var warnings = result.Output.Where(line => line.Contains(": warning")); | 39 | var warnings = result.Output.Where(line => line.Contains(": warning")); |
| @@ -71,6 +71,7 @@ namespace WixToolsetTest.MSBuild | |||
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | [Theory] | 73 | [Theory] |
| 74 | [InlineData(BuildSystem.DotNetCoreSdk)] | ||
| 74 | [InlineData(BuildSystem.MSBuild)] | 75 | [InlineData(BuildSystem.MSBuild)] |
| 75 | [InlineData(BuildSystem.MSBuild64)] | 76 | [InlineData(BuildSystem.MSBuild64)] |
| 76 | public void CanBuildHeatFileWithMultipleFilesPackage(BuildSystem buildSystem) | 77 | public void CanBuildHeatFileWithMultipleFilesPackage(BuildSystem buildSystem) |
| @@ -88,9 +89,7 @@ namespace WixToolsetTest.MSBuild | |||
| 88 | var result = MsbuildUtilities.BuildProject(buildSystem, projectPath); | 89 | var result = MsbuildUtilities.BuildProject(buildSystem, projectPath); |
| 89 | result.AssertSuccess(); | 90 | result.AssertSuccess(); |
| 90 | 91 | ||
| 91 | var expectedOutOfProc = false; | 92 | var heatCommandLines = MsbuildUtilities.GetToolCommandLines(result, "heat", "file", buildSystem); |
| 92 | var expectedHeatCommand = $"{(expectedOutOfProc ? "heat.exe" : "(heat.exe)")} file"; | ||
| 93 | var heatCommandLines = result.Output.Where(line => line.Contains(expectedHeatCommand)); | ||
| 94 | Assert.Equal(2, heatCommandLines.Count()); | 93 | Assert.Equal(2, heatCommandLines.Count()); |
| 95 | 94 | ||
| 96 | var warnings = result.Output.Where(line => line.Contains(": warning")); | 95 | var warnings = result.Output.Where(line => line.Contains(": warning")); |
diff --git a/src/test/WixToolsetTest.MSBuild/MsbuildUtilities.cs b/src/test/WixToolsetTest.MSBuild/MsbuildUtilities.cs index 6a6f32e0..90c3194b 100644 --- a/src/test/WixToolsetTest.MSBuild/MsbuildUtilities.cs +++ b/src/test/WixToolsetTest.MSBuild/MsbuildUtilities.cs | |||
| @@ -5,10 +5,12 @@ namespace WixToolsetTest.MSBuild | |||
| 5 | using System; | 5 | using System; |
| 6 | using System.Collections.Generic; | 6 | using System.Collections.Generic; |
| 7 | using System.IO; | 7 | using System.IO; |
| 8 | using System.Linq; | ||
| 8 | using WixBuildTools.TestSupport; | 9 | using WixBuildTools.TestSupport; |
| 9 | 10 | ||
| 10 | public enum BuildSystem | 11 | public enum BuildSystem |
| 11 | { | 12 | { |
| 13 | DotNetCoreSdk, | ||
| 12 | MSBuild, | 14 | MSBuild, |
| 13 | MSBuild64, | 15 | MSBuild64, |
| 14 | } | 16 | } |
| @@ -17,12 +19,13 @@ namespace WixToolsetTest.MSBuild | |||
| 17 | { | 19 | { |
| 18 | public static readonly string WixPropsPath = Path.Combine(new Uri(typeof(MsbuildUtilities).Assembly.CodeBase).AbsolutePath, "..", "..", "publish", "WixToolset.MSBuild", "build", "WixToolset.MSBuild.props"); | 20 | public static readonly string WixPropsPath = Path.Combine(new Uri(typeof(MsbuildUtilities).Assembly.CodeBase).AbsolutePath, "..", "..", "publish", "WixToolset.MSBuild", "build", "WixToolset.MSBuild.props"); |
| 19 | 21 | ||
| 20 | public static MsbuildRunnerResult BuildProject(BuildSystem buildSystem, string projectPath, string[] arguments = null, string configuration = "Release", bool? outOfProc = null) | 22 | public static MsbuildRunnerResult BuildProject(BuildSystem buildSystem, string projectPath, string[] arguments = null, string configuration = "Release", bool? outOfProc = null, string verbosityLevel = "normal") |
| 21 | { | 23 | { |
| 22 | var allArgs = new List<string> | 24 | var allArgs = new List<string> |
| 23 | { | 25 | { |
| 26 | $"-verbosity:{verbosityLevel}", | ||
| 24 | $"-p:Configuration={configuration}", | 27 | $"-p:Configuration={configuration}", |
| 25 | $"-p:WixMSBuildProps={MsbuildUtilities.WixPropsPath}", | 28 | GetQuotedPropertySwitch(buildSystem, "WixMSBuildProps", MsbuildUtilities.WixPropsPath), |
| 26 | // Node reuse means that child msbuild processes can stay around after the build completes. | 29 | // Node reuse means that child msbuild processes can stay around after the build completes. |
| 27 | // Under that scenario, the root msbuild does not reliably close its streams which causes us to hang. | 30 | // Under that scenario, the root msbuild does not reliably close its streams which causes us to hang. |
| 28 | "-nr:false", | 31 | "-nr:false", |
| @@ -40,6 +43,16 @@ namespace WixToolsetTest.MSBuild | |||
| 40 | 43 | ||
| 41 | switch (buildSystem) | 44 | switch (buildSystem) |
| 42 | { | 45 | { |
| 46 | case BuildSystem.DotNetCoreSdk: | ||
| 47 | { | ||
| 48 | allArgs.Add(projectPath); | ||
| 49 | var result = DotnetRunner.Execute("msbuild", allArgs.ToArray()); | ||
| 50 | return new MsbuildRunnerResult | ||
| 51 | { | ||
| 52 | ExitCode = result.ExitCode, | ||
| 53 | Output = result.StandardOutput, | ||
| 54 | }; | ||
| 55 | } | ||
| 43 | case BuildSystem.MSBuild: | 56 | case BuildSystem.MSBuild: |
| 44 | case BuildSystem.MSBuild64: | 57 | case BuildSystem.MSBuild64: |
| 45 | { | 58 | { |
| @@ -51,5 +64,34 @@ namespace WixToolsetTest.MSBuild | |||
| 51 | } | 64 | } |
| 52 | } | 65 | } |
| 53 | } | 66 | } |
| 67 | |||
| 68 | public static string GetQuotedPropertySwitch(BuildSystem buildSystem, string propertyName, string valueToQuote) | ||
| 69 | { | ||
| 70 | switch (buildSystem) | ||
| 71 | { | ||
| 72 | case BuildSystem.DotNetCoreSdk: | ||
| 73 | { | ||
| 74 | return $"-p:{propertyName}=\\\"{valueToQuote}\\\""; | ||
| 75 | } | ||
| 76 | case BuildSystem.MSBuild: | ||
| 77 | case BuildSystem.MSBuild64: | ||
| 78 | { | ||
| 79 | return $"-p:{propertyName}=\"{valueToQuote}\""; | ||
| 80 | } | ||
| 81 | default: | ||
| 82 | { | ||
| 83 | throw new NotImplementedException(); | ||
| 84 | } | ||
| 85 | } | ||
| 86 | } | ||
| 87 | |||
| 88 | public static IEnumerable<string> GetToolCommandLines(MsbuildRunnerResult result, string toolName, string operation, BuildSystem buildSystem, bool? outOfProc = null) | ||
| 89 | { | ||
| 90 | var expectedOutOfProc = buildSystem == BuildSystem.DotNetCoreSdk || outOfProc.HasValue && outOfProc.Value; | ||
| 91 | var expectedToolExe = !expectedOutOfProc ? $"({toolName}.exe)" : | ||
| 92 | buildSystem == BuildSystem.DotNetCoreSdk ? $"{toolName}.dll\"" : $"{toolName}.exe"; | ||
| 93 | var expectedToolCommand = $"{expectedToolExe} {operation}"; | ||
| 94 | return result.Output.Where(line => line.Contains(expectedToolCommand)); | ||
| 95 | } | ||
| 54 | } | 96 | } |
| 55 | } | 97 | } |
