Remove empty PATH in path resolver (#8943)

This commit is contained in:
William Lee 2018-03-30 16:05:41 -07:00 committed by GitHub
parent 5983fa1a2c
commit a67d1c6e06
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 0 deletions

View file

@ -47,6 +47,7 @@ namespace Microsoft.DotNet.Cli.Utils
.GetEnvironmentVariable("PATH")
.Split(s_pathSeparator)
.Select(p => p.Trim(s_quote))
.Where(p => !string.IsNullOrWhiteSpace(p))
.Select(p => ExpandTildeSlash(p)));
_searchPaths = searchPaths;

View file

@ -33,6 +33,11 @@ namespace Microsoft.DotNet.ShellShim
var existingUserEnvPath = Environment.GetEnvironmentVariable(PathName, EnvironmentVariableTarget.User);
if (existingUserEnvPath.EndsWith(';'))
{
existingUserEnvPath = existingUserEnvPath.Substring(0, (existingUserEnvPath.Length - 1));
}
Environment.SetEnvironmentVariable(
PathName,
$"{existingUserEnvPath};{_packageExecutablePath}",