when process has not env, but future will, show the instruction (#8739)

This commit is contained in:
William Lee 2018-03-07 19:46:38 -08:00 committed by GitHub
parent 2e7c5f123a
commit 495630fe97
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -40,10 +40,19 @@ namespace Microsoft.DotNet.ShellShim
}
private bool PackageExecutablePathExists()
{
return PackageExecutablePathExistsForCurrentProcess() || PackageExecutablePathWillExistForFutureNewProcess();
}
private bool PackageExecutablePathWillExistForFutureNewProcess()
{
return EnvironmentVariableConatinsPackageExecutablePath(Environment.GetEnvironmentVariable(PathName, EnvironmentVariableTarget.User))
|| EnvironmentVariableConatinsPackageExecutablePath(Environment.GetEnvironmentVariable(PathName, EnvironmentVariableTarget.Machine))
|| EnvironmentVariableConatinsPackageExecutablePath(Environment.GetEnvironmentVariable(PathName, EnvironmentVariableTarget.Process));
|| EnvironmentVariableConatinsPackageExecutablePath(Environment.GetEnvironmentVariable(PathName, EnvironmentVariableTarget.Machine));
}
private bool PackageExecutablePathExistsForCurrentProcess()
{
return EnvironmentVariableConatinsPackageExecutablePath(Environment.GetEnvironmentVariable(PathName, EnvironmentVariableTarget.Process));
}
private bool EnvironmentVariableConatinsPackageExecutablePath(string environmentVariable)
@ -58,21 +67,17 @@ namespace Microsoft.DotNet.ShellShim
public void PrintAddPathInstructionIfPathDoesNotExist()
{
if (!PackageExecutablePathExists())
if (!PackageExecutablePathExistsForCurrentProcess() && PackageExecutablePathWillExistForFutureNewProcess())
{
if (Environment.GetEnvironmentVariable(PathName, EnvironmentVariableTarget.User).Split(';')
.Contains(_packageExecutablePath))
{
_reporter.WriteLine(
CommonLocalizableStrings.EnvironmentPathWindowsNeedReopen);
}
else
{
_reporter.WriteLine(
string.Format(
CommonLocalizableStrings.EnvironmentPathWindowsManualInstructions,
_packageExecutablePath));
}
_reporter.WriteLine(
CommonLocalizableStrings.EnvironmentPathWindowsNeedReopen);
}
else if (!PackageExecutablePathWillExistForFutureNewProcess())
{
_reporter.WriteLine(
string.Format(
CommonLocalizableStrings.EnvironmentPathWindowsManualInstructions,
_packageExecutablePath));
}
}
}