Skip to content

Commit

Permalink
environment: fix environment process locator
Browse files Browse the repository at this point in the history
Fix a bug in the WindowsEnvironment implementation of the
LocateExectuable method. On .NET Core the UseShellExecute property of
ProcessStartInfo defaults to false, whereas on .NET Framework (the
runtime that we target on Windows) defaults to true. You must set this
to false if you want to redirect standard streams (which we want to do).

The .NET Framework-targeting build on Windows was throwing an exception
here(!)
  • Loading branch information
mjcheetham committed Sep 17, 2020
1 parent e817723 commit 245c05e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public override string LocateExecutable(string program)
const string whichPath = "/usr/bin/which";
var psi = new ProcessStartInfo(whichPath, program)
{
UseShellExecute = false,
RedirectStandardOutput = true
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public override string LocateExecutable(string program)
string wherePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "where.exe");
var psi = new ProcessStartInfo(wherePath, program)
{
UseShellExecute = false,
RedirectStandardOutput = true
};

Expand Down

0 comments on commit 245c05e

Please sign in to comment.