Update MSBuildRunner to ignore previous VS versions
Ron Martin committed
Mar 5, 2022 at 14:42 UTC
64fc0adbf4b910314223cbcfeaf2d8b72f0f760e
1 file changed
+2
-58
src/internal/WixBuildTools.TestSupport/MsbuildRunner.cs
+2
-58
@@ -8,26 +8,19 @@ namespace WixBuildTools.TestSupport
8
9
public class MsbuildRunner : ExternalExecutable
10
{
11
- private static readonly string VswhereFindArguments = "-property installationPath";
12
- private static readonly string Msbuild15RelativePath = @"MSBuild\15.0\Bin\MSBuild.exe";
13
- private static readonly string Msbuild15RelativePath64 = @"MSBuild\15.0\Bin\amd64\MSBuild.exe";
11
+ private static readonly string VswhereFindArguments = "-property installationPath -version [17.0,18.0)";
12
private static readonly string MsbuildCurrentRelativePath = @"MSBuild\Current\Bin\MSBuild.exe";
13
private static readonly string MsbuildCurrentRelativePath64 = @"MSBuild\Current\Bin\amd64\MSBuild.exe";
14
15
private static readonly object InitLock = new object();
16
17
private static bool Initialized;
20
- private static MsbuildRunner Msbuild15Runner;
21
- private static MsbuildRunner Msbuild15Runner64;
18
private static MsbuildRunner MsbuildCurrentRunner;
19
private static MsbuildRunner MsbuildCurrentRunner64;
20
21
public static MsbuildRunnerResult Execute(string projectPath, string[] arguments = null, bool x64 = false) =>
22
InitAndExecute(String.Empty, projectPath, arguments, x64);
23
28
- public static MsbuildRunnerResult ExecuteWithMsbuild15(string projectPath, string[] arguments = null, bool x64 = false) =>
29
- InitAndExecute("15", projectPath, arguments, x64);
30
-
24
public static MsbuildRunnerResult ExecuteWithMsbuildCurrent(string projectPath, string[] arguments = null, bool x64 = false) =>
25
InitAndExecute("Current", projectPath, arguments, x64);
26
@@ -44,8 +37,6 @@ namespace WixBuildTools.TestSupport
37
throw new InvalidOperationException($"Failed to execute vswhere.exe, exit code: {vswhereResult.ExitCode}. Output:\r\n{String.Join("\r\n", vswhereResult.StandardOutput)}");
38
}
39
47
- string msbuild15Path = null;
48
- string msbuild15Path64 = null;
40
string msbuildCurrentPath = null;
41
string msbuildCurrentPath64 = null;
42
@@ -68,24 +59,6 @@ namespace WixBuildTools.TestSupport
59
msbuildCurrentPath64 = path;
60
}
61
}
71
-
72
- if (msbuild15Path == null)
73
- {
74
- var path = Path.Combine(installPath, Msbuild15RelativePath);
75
- if (File.Exists(path))
76
- {
77
- msbuild15Path = path;
78
- }
79
- }
80
-
81
- if (msbuild15Path64 == null)
82
- {
83
- var path = Path.Combine(installPath, Msbuild15RelativePath64);
84
- if (File.Exists(path))
85
- {
86
- msbuild15Path64 = path;
87
- }
88
- }
62
}
63
64
if (msbuildCurrentPath != null)
@@ -97,39 +70,10 @@ namespace WixBuildTools.TestSupport
70
{
71
MsbuildCurrentRunner64 = new MsbuildRunner(msbuildCurrentPath64);
72
}
100
-
101
- if (msbuild15Path != null)
102
- {
103
- Msbuild15Runner = new MsbuildRunner(msbuild15Path);
104
- }
105
-
106
- if (msbuild15Path64 != null)
107
- {
108
- Msbuild15Runner64 = new MsbuildRunner(msbuild15Path64);
109
- }
73
}
74
}
75
113
- MsbuildRunner runner;
114
- switch (msbuildVersion)
115
- {
116
- case "15":
117
- {
118
- runner = x64 ? Msbuild15Runner64 : Msbuild15Runner;
119
- break;
120
- }
121
- case "Current":
122
- {
123
- runner = x64 ? MsbuildCurrentRunner64 : MsbuildCurrentRunner;
124
- break;
125
- }
126
- default:
127
- {
128
- runner = x64 ? MsbuildCurrentRunner64 ?? Msbuild15Runner64
129
- : MsbuildCurrentRunner ?? Msbuild15Runner;
130
- break;
131
- }
132
- }
76
+ MsbuildRunner runner = x64 ? MsbuildCurrentRunner64 : MsbuildCurrentRunner;
77
78
if (runner == null)
79
{