summaryrefslogtreecommitdiff
path: root/src/wix/test/WixToolsetTest.Sdk/MsbuildUtilities.cs
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2022-07-26 17:20:39 -0700
committerRob Mensching <rob@firegiant.com>2022-08-01 20:25:19 -0700
commita627ca9b720047e633a8fe72003ab9bee31006c5 (patch)
tree2bc8a924bb4141ab718e74d08f6459a0ffe8d573 /src/wix/test/WixToolsetTest.Sdk/MsbuildUtilities.cs
parent521eb3c9cf38823a2c4019abb85dc0b3200b92cb (diff)
downloadwix-a627ca9b720047e633a8fe72003ab9bee31006c5.tar.gz
wix-a627ca9b720047e633a8fe72003ab9bee31006c5.tar.bz2
wix-a627ca9b720047e633a8fe72003ab9bee31006c5.zip
Create WixToolset.Heat.nupkg to distribute heat.exe and Heat targets
Moves Heat functionality to the "tools" layer and packages it all up in WixToolset.Heat.nupkg for distribution in WiX v4. Completes 6838
Diffstat (limited to 'src/wix/test/WixToolsetTest.Sdk/MsbuildUtilities.cs')
-rw-r--r--src/wix/test/WixToolsetTest.Sdk/MsbuildUtilities.cs100
1 files changed, 0 insertions, 100 deletions
diff --git a/src/wix/test/WixToolsetTest.Sdk/MsbuildUtilities.cs b/src/wix/test/WixToolsetTest.Sdk/MsbuildUtilities.cs
deleted file mode 100644
index 028ea0cf..00000000
--- a/src/wix/test/WixToolsetTest.Sdk/MsbuildUtilities.cs
+++ /dev/null
@@ -1,100 +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
3namespace WixToolsetTest.Sdk
4{
5 using System;
6 using System.Collections.Generic;
7 using System.IO;
8 using System.Linq;
9 using WixBuildTools.TestSupport;
10
11 public enum BuildSystem
12 {
13 DotNetCoreSdk,
14 MSBuild,
15 MSBuild64,
16 }
17
18 public static class MsbuildUtilities
19 {
20 public static readonly string WixMsbuildPath = Path.Combine(Path.GetDirectoryName(new Uri(typeof(MsbuildUtilities).Assembly.CodeBase).AbsolutePath), "..", "..", "..", "publish", "WixToolset.Sdk");
21 public static readonly string WixPropsPath = Path.Combine(WixMsbuildPath, "build", "WixToolset.Sdk.props");
22
23 public static MsbuildRunnerResult BuildProject(BuildSystem buildSystem, string projectPath, string[] arguments = null, string configuration = "Release", bool? outOfProc = null, string verbosityLevel = "normal", bool suppressValidation = true)
24 {
25 var allArgs = new List<string>
26 {
27 $"-verbosity:{verbosityLevel}",
28 $"-p:Configuration={configuration}",
29 $"-p:SuppressValidation={suppressValidation}",
30 GetQuotedPropertySwitch(buildSystem, "WixMSBuildProps", MsbuildUtilities.WixPropsPath),
31 // Node reuse means that child msbuild processes can stay around after the build completes.
32 // Under that scenario, the root msbuild does not reliably close its streams which causes us to hang.
33 "-nr:false",
34 $"-bl:{Path.ChangeExtension(projectPath, ".binlog")}"
35 };
36
37 if (outOfProc.HasValue)
38 {
39 allArgs.Add($"-p:RunWixToolsOutOfProc={outOfProc.Value}");
40 }
41
42 if (arguments != null)
43 {
44 allArgs.AddRange(arguments);
45 }
46
47 switch (buildSystem)
48 {
49 case BuildSystem.DotNetCoreSdk:
50 {
51 allArgs.Add(projectPath);
52 var result = DotnetRunner.Execute("msbuild", allArgs.ToArray());
53 return new MsbuildRunnerResult
54 {
55 ExitCode = result.ExitCode,
56 Output = result.StandardOutput,
57 };
58 }
59 case BuildSystem.MSBuild:
60 case BuildSystem.MSBuild64:
61 {
62 return MsbuildRunner.Execute(projectPath, allArgs.ToArray(), buildSystem == BuildSystem.MSBuild64);
63 }
64 default:
65 {
66 throw new NotImplementedException();
67 }
68 }
69 }
70
71 public static string GetQuotedPropertySwitch(BuildSystem buildSystem, string propertyName, string valueToQuote)
72 {
73 switch (buildSystem)
74 {
75 case BuildSystem.DotNetCoreSdk:
76 {
77 return $"-p:{propertyName}=\\\"{valueToQuote}\\\"";
78 }
79 case BuildSystem.MSBuild:
80 case BuildSystem.MSBuild64:
81 {
82 return $"-p:{propertyName}=\"{valueToQuote}\"";
83 }
84 default:
85 {
86 throw new NotImplementedException();
87 }
88 }
89 }
90
91 public static IEnumerable<string> GetToolCommandLines(MsbuildRunnerResult result, string toolName, string operation, BuildSystem buildSystem, bool? outOfProc = null)
92 {
93 var expectedOutOfProc = buildSystem == BuildSystem.DotNetCoreSdk || outOfProc.HasValue && outOfProc.Value;
94 var expectedToolExe = !expectedOutOfProc ? $"({toolName}.exe)" :
95 buildSystem == BuildSystem.DotNetCoreSdk ? $"{toolName}.dll\"" : $"{toolName}.exe";
96 var expectedToolCommand = $"{expectedToolExe} {operation}";
97 return result.Output.Where(line => line.Contains(expectedToolCommand));
98 }
99 }
100}