Skip to content

Remove env var workaround that causes dotnet to use MSBuild out-of-proc #49750

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

baronfel
Copy link
Member

Per the comment, to work around dotnet/runtime#50554 the CLI would silently shift to out-of-proc mode.

However, this issue was addressed in .NET 8, so we can remove the workaround in the dotnet CLI since main always runs on 10+ runtimes.

@Copilot Copilot AI review requested due to automatic review settings July 12, 2025 14:37
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Removes the legacy workaround that forced MSBuild to run out-of-proc when environment variables were empty or contained a null character, since this issue is fixed in .NET 8 and the CLI now targets runtimes 10+.

  • Deletes the if (value == string.Empty || value == "\0") block and related fallback calls in EnvironmentVariable
  • Simplifies the MSBuild forwarding code by assuming in-proc support for empty env values
Comments suppressed due to low confidence (1)

src/Cli/Microsoft.DotNet.Cli.Utils/MSBuildForwardingAppWithoutLogging.cs:114

  • [nitpick] Consider adding a comment here explaining that the out-of-proc fallback for empty or '\0' environment values has been removed because the underlying runtime issue is fixed in .NET 8, to guide future maintainers.
    public void EnvironmentVariable(string name, string value)

@@ -121,17 +121,6 @@ public void EnvironmentVariable(string name, string value)
{
_msbuildRequiredEnvironmentVariables.Add(name, value);
Copy link
Preview

Copilot AI Jul 12, 2025

Choose a reason for hiding this comment

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

The removal of the fallback for empty or null-character environment values changes behavior for those inputs; please add or update tests to cover setting environment variables with an empty string or '\0' to ensure correct in-proc behavior on .NET 8+.

Copilot uses AI. Check for mistakes.

@baronfel baronfel requested a review from a team July 12, 2025 17:41
@baronfel baronfel changed the title Remove env var workaround that cause dotnet to use MSBuild out-of-proc Remove env var workaround that causes dotnet to use MSBuild out-of-proc Jul 12, 2025
Copy link
Member

@dsplaisted dsplaisted left a comment

Choose a reason for hiding this comment

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

Should we have any tests for this? Was there a scenario to verify manually?

@baronfel
Copy link
Member Author

@dsplaisted that's part of why I sent the PR - to see if CI had any test cases that would fail :D I suppose I can make a test app that echos a specific environment variable, and then try to trigger that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants