aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Martin <cpuwzd@comcast.net>2022-03-05 14:42:13 -0500
committerRob Mensching <rob@firegiant.com>2022-03-09 16:31:01 -0800
commit64fc0adbf4b910314223cbcfeaf2d8b72f0f760e (patch)
tree01cd563b3e34f6236fef71f6a3519f1929c6cde6
parent67274acee7b9b4d989cf354f7cc3f1665d12b80c (diff)
downloadwix-64fc0adbf4b910314223cbcfeaf2d8b72f0f760e.tar.gz
wix-64fc0adbf4b910314223cbcfeaf2d8b72f0f760e.tar.bz2
wix-64fc0adbf4b910314223cbcfeaf2d8b72f0f760e.zip
Update MSBuildRunner to ignore previous VS versions
-rw-r--r--src/internal/WixBuildTools.TestSupport/MsbuildRunner.cs60
1 files changed, 2 insertions, 58 deletions
diff --git a/src/internal/WixBuildTools.TestSupport/MsbuildRunner.cs b/src/internal/WixBuildTools.TestSupport/MsbuildRunner.cs
index 35e53de6..ac7caf0e 100644
--- a/src/internal/WixBuildTools.TestSupport/MsbuildRunner.cs
+++ b/src/internal/WixBuildTools.TestSupport/MsbuildRunner.cs
@@ -8,26 +8,19 @@ namespace WixBuildTools.TestSupport
8 8
9 public class MsbuildRunner : ExternalExecutable 9 public class MsbuildRunner : ExternalExecutable
10 { 10 {
11 private static readonly string VswhereFindArguments = "-property installationPath"; 11 private static readonly string VswhereFindArguments = "-property installationPath -version [17.0,18.0)";
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";
14 private static readonly string MsbuildCurrentRelativePath = @"MSBuild\Current\Bin\MSBuild.exe"; 12 private static readonly string MsbuildCurrentRelativePath = @"MSBuild\Current\Bin\MSBuild.exe";
15 private static readonly string MsbuildCurrentRelativePath64 = @"MSBuild\Current\Bin\amd64\MSBuild.exe"; 13 private static readonly string MsbuildCurrentRelativePath64 = @"MSBuild\Current\Bin\amd64\MSBuild.exe";
16 14
17 private static readonly object InitLock = new object(); 15 private static readonly object InitLock = new object();
18 16
19 private static bool Initialized; 17 private static bool Initialized;
20 private static MsbuildRunner Msbuild15Runner;
21 private static MsbuildRunner Msbuild15Runner64;
22 private static MsbuildRunner MsbuildCurrentRunner; 18 private static MsbuildRunner MsbuildCurrentRunner;
23 private static MsbuildRunner MsbuildCurrentRunner64; 19 private static MsbuildRunner MsbuildCurrentRunner64;
24 20
25 public static MsbuildRunnerResult Execute(string projectPath, string[] arguments = null, bool x64 = false) => 21 public static MsbuildRunnerResult Execute(string projectPath, string[] arguments = null, bool x64 = false) =>
26 InitAndExecute(String.Empty, projectPath, arguments, x64); 22 InitAndExecute(String.Empty, projectPath, arguments, x64);
27 23
28 public static MsbuildRunnerResult ExecuteWithMsbuild15(string projectPath, string[] arguments = null, bool x64 = false) =>
29 InitAndExecute("15", projectPath, arguments, x64);
30
31 public static MsbuildRunnerResult ExecuteWithMsbuildCurrent(string projectPath, string[] arguments = null, bool x64 = false) => 24 public static MsbuildRunnerResult ExecuteWithMsbuildCurrent(string projectPath, string[] arguments = null, bool x64 = false) =>
32 InitAndExecute("Current", projectPath, arguments, x64); 25 InitAndExecute("Current", projectPath, arguments, x64);
33 26
@@ -44,8 +37,6 @@ namespace WixBuildTools.TestSupport
44 throw new InvalidOperationException($"Failed to execute vswhere.exe, exit code: {vswhereResult.ExitCode}. Output:\r\n{String.Join("\r\n", vswhereResult.StandardOutput)}"); 37 throw new InvalidOperationException($"Failed to execute vswhere.exe, exit code: {vswhereResult.ExitCode}. Output:\r\n{String.Join("\r\n", vswhereResult.StandardOutput)}");
45 } 38 }
46 39
47 string msbuild15Path = null;
48 string msbuild15Path64 = null;
49 string msbuildCurrentPath = null; 40 string msbuildCurrentPath = null;
50 string msbuildCurrentPath64 = null; 41 string msbuildCurrentPath64 = null;
51 42
@@ -68,24 +59,6 @@ namespace WixBuildTools.TestSupport
68 msbuildCurrentPath64 = path; 59 msbuildCurrentPath64 = path;
69 } 60 }
70 } 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 }
89 } 62 }
90 63
91 if (msbuildCurrentPath != null) 64 if (msbuildCurrentPath != null)
@@ -97,39 +70,10 @@ namespace WixBuildTools.TestSupport
97 { 70 {
98 MsbuildCurrentRunner64 = new MsbuildRunner(msbuildCurrentPath64); 71 MsbuildCurrentRunner64 = new MsbuildRunner(msbuildCurrentPath64);
99 } 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 }
110 } 73 }
111 } 74 }
112 75
113 MsbuildRunner runner; 76 MsbuildRunner runner = x64 ? MsbuildCurrentRunner64 : MsbuildCurrentRunner;
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 }
133 77
134 if (runner == null) 78 if (runner == null)
135 { 79 {