Bring back logic to remove unwanted env variables (#20326)
This commit is contained in:
parent
df1252a3f8
commit
cba5387f28
|
|
@ -52,6 +52,7 @@ namespace Microsoft.AspNetCore.Builder
|
||||||
UseShellExecute = false,
|
UseShellExecute = false,
|
||||||
RedirectStandardOutput = true,
|
RedirectStandardOutput = true,
|
||||||
};
|
};
|
||||||
|
RemoveUnwantedEnvironmentVariables(processStartInfo.Environment);
|
||||||
|
|
||||||
var debugProxyProcess = Process.Start(processStartInfo);
|
var debugProxyProcess = Process.Start(processStartInfo);
|
||||||
CompleteTaskWhenServerIsReady(debugProxyProcess, tcs);
|
CompleteTaskWhenServerIsReady(debugProxyProcess, tcs);
|
||||||
|
|
@ -64,6 +65,21 @@ namespace Microsoft.AspNetCore.Builder
|
||||||
return await tcs.Task;
|
return await tcs.Task;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void RemoveUnwantedEnvironmentVariables(IDictionary<string, string> environment)
|
||||||
|
{
|
||||||
|
// Generally we expect to pass through most environment variables, since dotnet might
|
||||||
|
// need them for arbitrary reasons to function correctly. However, we specifically don't
|
||||||
|
// want to pass through any ASP.NET Core hosting related ones, since the child process
|
||||||
|
// shouldn't be trying to use the same port numbers, etc. In particular we need to break
|
||||||
|
// the association with IISExpress and the MS-ASPNETCORE-TOKEN check.
|
||||||
|
// For more context on this, see https://github.com/dotnet/aspnetcore/issues/20308.
|
||||||
|
var keysToRemove = environment.Keys.Where(key => key.StartsWith("ASPNETCORE_")).ToList();
|
||||||
|
foreach (var key in keysToRemove)
|
||||||
|
{
|
||||||
|
environment.Remove(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static string LocateDebugProxyExecutable(IWebHostEnvironment environment)
|
private static string LocateDebugProxyExecutable(IWebHostEnvironment environment)
|
||||||
{
|
{
|
||||||
var assembly = Assembly.Load(environment.ApplicationName);
|
var assembly = Assembly.Load(environment.ApplicationName);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue