Skip to content

C# Doctor: 'Correct .NET environment' writes a ~/.zshrc block pinning a below-minimum .NET root, then asks to relaunch (macOS, no dotnetup) #3881

Open

Description

@JakeRadMSFT

Describe the issue

On a fresh macOS machine where the only .NET is the official .pkg install at /usr/local/share/dotnet (SDK 10.0.301, below the 10.0.400 minimum) and dotnetup is not installed, C# Doctor offers Correct .NET environment as the fix. Clicking it:

  1. finishes in ~150 ms without installing anything,
  2. writes a block to ~/.zshrc that pins new shells to the same below-minimum root:
    # >>> C# Dev Kit .NET environment >>>
    export DOTNET_ROOT='/usr/local/share/dotnet'
    case "${PATH-}" in
        '/usr/local/share/dotnet'|'/usr/local/share/dotnet':*) ;;
        *) export PATH='/usr/local/share/dotnet'"${PATH:+:$PATH}" ;;
    esac
    # <<< C# Dev Kit .NET environment <<<
  3. tells the user to relaunch VS Code.

After the relaunch nothing has changed: the same 10.0.301 SDK is selected and Doctor now offers Install .NET 10 SDK. That install (via dotnetup) works and dotnetup adds its own .zshrc block after ours, so new shells end up on the dotnetup root, but the stale C# Dev Kit block that points at /usr/local/share/dotnet is left behind in ~/.zshrc.

So the first action offered is a no-op that edits the user's shell profile and costs a relaunch, and it leaves a contradictory profile entry.

Collect logs

No .NET: Collect C# Dev Kit Logs zip attached yet (available on request). Relevant C# Dev Kit.log lines:

[warning] The Visual Studio Code process environment candidate "/usr/local/share/dotnet/dotnet" selected SDK 10.0.301, which is older than the minimum supported SDK 10.0.400. ...
[info] Starting: Correct .NET environment
[info] Starting: Discover existing dotnetup environment repair targets
[info] Completed: Discover existing dotnetup environment repair targets (1ms)
[info] Completed: Correct .NET environment (148ms)
... (relaunch) ...
[info] Workspace tooling auto-resolution is installing stable SDK 10.0.400 using managed-user-profile ownership.
[info] [dotnetup stdout] Installing .NET SDK 10.0.404 to ~/Library/Application Support/dotnetup/dotnet...
[info] Switching new shells from use-only .NET root "/usr/local/share/dotnet" to dotnetup root "~/Library/Application Support/dotnetup/dotnet" ...

Steps to reproduce

  1. macOS (arm64). Only the official .NET .pkg is installed at /usr/local/share/dotnet with SDKs up to 10.0.301. No dotnetup (~/.dotnetup and ~/Library/Application Support/dotnetup absent), no DOTNET_ROOT, no .NET lines in ~/.zshrc.
  2. Open a folder with a net11.0 console project (no global.json).
  3. Open C# Doctor. Tooling Requirements is blocked (10.0.301 < 10.0.400) and Correct .NET environment is offered.
  4. Click it. Doctor reports success and asks to relaunch.
  5. Inspect ~/.zshrc and relaunch VS Code.

Expected behavior

  • Doctor should never write a shell-profile block that points DOTNET_ROOT/PATH at a root whose SDK does not meet the minimum. The environment fix should only be offered when the target root actually qualifies.
  • In this setup the single action should be Install .NET SDK (via dotnetup, into the user root), followed by shell setup and a restart/reboot notice.
  • When an install switches new shells to the dotnetup root, any existing C# Dev Kit environment block that points elsewhere should be removed.

Related, but separate: for a net11.0 project the first install offered is .NET 10 (product minimum), because project evaluation can't run yet; a second Install .NET 11 SDK step follows after relaunch.

Environment information

  • OS: macOS 27.2.1 (arm64)
  • VS Code version: 1.146.0
  • C# Dev Kit version: 11.11.107 (prerelease)
  • C# extension version: 11.11.43 (prerelease)

Additional evidence (optional)

Related: #3809 (asdf SDK below minimum, no Resolve), #3807 (Resolve fails with "selected host changed").


🤖 Filed by an agent on behalf of Jake (@JakeRadMSFT) — reply here with any missing repro detail.

Activity

  1. added
    bug
    on Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions