diff options
| author | Sean Hall <r.sean.hall@gmail.com> | 2020-06-03 12:31:23 +1000 |
|---|---|---|
| committer | Sean Hall <r.sean.hall@gmail.com> | 2020-06-03 14:24:34 +1000 |
| commit | be9b04d2272ef9a9e811d2d5486593b628a68993 (patch) | |
| tree | 6527d1394aac1d67c8e4e9bd3ed6ae60b184a6eb /src/test/WixToolsetTest.MSBuild/MsbuildUtilities.cs | |
| parent | d5d5e87acf7eadacd757083a4d0272a04962ae9b (diff) | |
| download | wix-be9b04d2272ef9a9e811d2d5486593b628a68993.tar.gz wix-be9b04d2272ef9a9e811d2d5486593b628a68993.tar.bz2 wix-be9b04d2272ef9a9e811d2d5486593b628a68993.zip | |
Never run in-proc on .NET Core.
Diffstat (limited to 'src/test/WixToolsetTest.MSBuild/MsbuildUtilities.cs')
| -rw-r--r-- | src/test/WixToolsetTest.MSBuild/MsbuildUtilities.cs | 46 |
1 files changed, 44 insertions, 2 deletions
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 | } |
