Skip to content

Commit

Permalink
Ensure dotnet is on the PATH for the remote PowerShell host
Browse files Browse the repository at this point in the history
VS Mac 17.0 creates the pad windows when the IDE window is first
shown, even if the pad is never opened or available docked. This means
the PATH used to launch the powershell console host does not contain
the path to the dotnet CLI which is configured when a project is
opened. To avoid this check for a valid dotnet runtime and set the
PATH for the powershell console host to be the parent process's PATH
environment variable with the path to dotnet appended.
  • Loading branch information
mrward committed Apr 10, 2022
1 parent 06569ec commit 6afdf3e
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ static Process StartPowerShellHost ()
RedirectStandardOutput = true
};

ConfigurePathEnvironmentVariable (info);

var process = new Process {
StartInfo = info
};
Expand All @@ -129,6 +131,27 @@ static Process StartPowerShellHost ()
return process;
}

/// <summary>
/// Ensure dotnet is on the PATH.
/// </summary>
static void ConfigurePathEnvironmentVariable (ProcessStartInfo info)
{
if (DotNetCoreRuntime.IsMissing) {
return;
}

string dotNetDirectory = Path.GetDirectoryName (DotNetCoreRuntime.FileName);
if (string.IsNullOrEmpty (dotNetDirectory)) {
return;
}

string path = Environment.GetEnvironmentVariable ("PATH");
if (!string.IsNullOrEmpty (path)) {
path += Path.PathSeparator + dotNetDirectory;
info.EnvironmentVariables ["PATH"] = path;
}
}

void JsonRpcDisconnected (object sender, JsonRpcDisconnectedEventArgs e)
{
string errorMessage = GettextCatalog.GetString (
Expand Down

0 comments on commit 6afdf3e

Please sign in to comment.