Skip to content

Commit fdd2ddc

Browse files
Try other path and blow up if neither found
XUnit doesn't show output so just checking this isn't the problem
1 parent 87ffabc commit fdd2ddc

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

CommandLine/CodeConv.Shared/CodeConvProgram.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,11 @@ private bool ShouldIncludeProject(Project project)
171171

172172
private static async Task<string?> GetLatestMsBuildExePathAsync()
173173
{
174-
var vsWhereExe = Environment.ExpandEnvironmentVariables(@"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe");
174+
// The second path here is available on github action agents: https://github.com/microsoft/setup-msbuild#how-does-this-work
175+
var pathsToCheck = new[] { @"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe", @"%ProgramData%\chocolatey\bin" }
176+
.Select(Environment.ExpandEnvironmentVariables);
177+
var vsWhereExe = pathsToCheck.FirstOrDefault(File.Exists)
178+
?? throw new FileNotFoundException($"Could not find VSWhere in: {string.Join(", ", pathsToCheck.Select(p => $"`{p}`"))}");
175179
var args = new[] { "-latest", "-prerelease", "-products", "*", "-requires", "Microsoft.Component.MSBuild", "-version", "[16.0,]", "-find", @"MSBuild\**\Bin\MSBuild.exe" };
176180

177181
var (exitCode, stdOut, _) = await new ProcessStartInfo(vsWhereExe) {

0 commit comments

Comments
 (0)