Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace Microsoft.DotNet.Cli.Utils
internal class MSBuildForwardingAppWithoutLogging
{
private static readonly bool AlwaysExecuteMSBuildOutOfProc = Env.GetEnvironmentVariableAsBool("DOTNET_CLI_RUN_MSBUILD_OUTOFPROC");
private static readonly bool DoNotUseMSBUILDNOINPROCNODE = Env.GetEnvironmentVariableAsBool("DOTNET_CLI_DO_NOT_USE_MSBUILDNOINPROCNODE");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Maybe remove the double negation: DOTNET_CLI_USE_MSBUILD_INPROC_NODE ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to keep name same as is the MSBUILD escape hatch toi avoid confusion between your OUTOFPROC and mine NOINPROC. People might get impression that OUTOFPROC == NOINPROC and get confused why we have two escapes for same thing. Ithough about DOTNET_CLI_DONT_USE_MSBUILD_SERVER_V1 but I believe it is confusing for anyone without knowledge of msbuild server background....


private const string MSBuildExeName = "MSBuild.dll";

Expand Down Expand Up @@ -53,6 +54,13 @@ public MSBuildForwardingAppWithoutLogging(IEnumerable<string> argsToForward, str
_argsToForward = argsToForward;
MSBuildPath = msbuildPath ?? defaultMSBuildPath;

if (!DoNotUseMSBUILDNOINPROCNODE)
{
// Force MSBuild to use external working node long living process for building projects
// We also refers to this as MSBuild Server V1 as entry process forwards most of the work to it.
EnvironmentVariable("MSBUILDNOINPROCNODE", "1");
}

// If DOTNET_CLI_RUN_MSBUILD_OUTOFPROC is set or we're asked to execute a non-default binary, call MSBuild out-of-proc.
if (AlwaysExecuteMSBuildOutOfProc || !string.Equals(MSBuildPath, defaultMSBuildPath, StringComparison.OrdinalIgnoreCase))
{
Expand Down Expand Up @@ -92,6 +100,8 @@ public void EnvironmentVariable(string name, string value)

if (value == string.Empty || value == "\0")
{
// Do not allow MSBuild NOIPROCNODE as null env vars are not properly transferred to build nodes
_msbuildRequiredEnvironmentVariables["MSBUILDNOINPROCNODE"] = "0";
// Unlike ProcessStartInfo.EnvironmentVariables, Environment.SetEnvironmentVariable can't set a variable
// to an empty value, so we just fall back to calling MSBuild out-of-proc if we encounter this case.
// https://github.com/dotnet/runtime/issues/50554
Expand Down