Skip to content

Cleanup DOTNET_ROOT logic for dotnet run #49913

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 10 commits into
base: main
Choose a base branch
from

Conversation

Youssef1313
Copy link
Member

@Youssef1313 Youssef1313 commented Jul 23, 2025

The logic around TargetFrameworkVersion appears to exist to support apps targeting net5.0 or earlier.

.NET 5 was out of support on May 10, 2022. I guess .NET 10 can safely drop this and clean this up?

cc @elinor-fung @baronfel Let me know your thoughts here please, and if there is something I'm missing.

This PR changes the behavior in the case of app targeting the same architecture as SDK, or app is targeting an unknown architecture. In this case:

  • Old behavior:
    • older than .NET 6 (likely including .NET Framework):
      • x64: we set DOTNET_ROOT
      • otherwise: we set DOTNET_ROOT(x86)
    • .NET 6 or later:
      • Always set DOTNET_ROOT_<ARCH>
  • New behavior:
    • Always set DOTNET_ROOT_<ARCH>, regardless of the target framework.

@Copilot Copilot AI review requested due to automatic review settings July 23, 2025 14:47
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

This PR removes legacy .NET 5.0 compatibility logic from the DOTNET_ROOT environment variable handling in the dotnet run command. The cleanup simplifies the codebase by removing support for .NET 5.0 and earlier versions, which reached end-of-support in May 2022.

Key changes:

  • Removed TargetFrameworkVersion parameter and related logic from DOTNET_ROOT variable name resolution
  • Simplified test cases to remove .NET 5.0-specific scenarios and legacy 32-bit process handling
  • Consolidated environment variable naming to use architecture-specific suffixes consistently

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/Common/EnvironmentVariableNames.cs Removes TargetFrameworkVersion parameter and legacy logic, simplifies to always use architecture-specific DOTNET_ROOT variables
src/Cli/dotnet/Commands/Run/RunCommand.cs Updates call site to remove TargetFrameworkVersion parameter
test/dotnet.Tests/EnvironmentVariableNamesTests.cs Simplifies test cases by removing .NET 5.0 scenarios and legacy 32-bit process handling
Comments suppressed due to low confidence (2)

test/dotnet.Tests/EnvironmentVariableNamesTests.cs:58

  • This test case expects 'DOTNET_ROOT' for x86 architecture, but the implementation now always returns architecture-specific variables like 'DOTNET_ROOT_X86'. This test case appears to be testing behavior that no longer exists.
    [InlineData("os-x86", Architecture.X86, "DOTNET_ROOT")]

test/dotnet.Tests/EnvironmentVariableNamesTests.cs:59

  • This test case expects 'DOTNET_ROOT' for x64 architecture, but the implementation now always returns architecture-specific variables like 'DOTNET_ROOT_X64'. This test case appears to be testing behavior that no longer exists.
    [InlineData("os-x64", Architecture.X64, "DOTNET_ROOT")]

@Youssef1313
Copy link
Member Author

@elinor-fung @baronfel Can I have your eyes on this change please?

Note: I want to reuse that for dotnet test, but I also don't want to set DOTNET_ROOT in any case. I prefer to always only set DOTNET_ROOT_<ARCH>. So I thought it might be good idea to clean this up as net5.0 is out-of-support for long and DOTNET_ROOT_<ARCH> should work fine on the supported TFMs.

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

Successfully merging this pull request may close these issues.

1 participant