Skip to content

global.json paths resolves SDK but runtimes from additional paths are not visible to the host #2862

@JakeRadMSFT

Description

@JakeRadMSFT

Description

The global.json paths property (new in .NET 10) correctly resolves the SDK from a local directory, but runtimes installed in that directory are not discovered by the host for test execution or dotnet --list-runtimes.

This affects repos like dotnet/aspire where restore.sh installs multiple .NET runtimes (8.0, 9.0, 10.0) into a local .dotnet directory and global.json uses "paths": [".dotnet", "$host$"] to point to them.

Reproduction

  1. Have a system-wide .NET install at /usr/local/share/dotnet with only .NET 10.0.3
  2. In a repo, run restore.sh which installs .NET 8.0.21, 9.0.10, and SDK 10.0.103 into a local .dotnet directory
  3. global.json has:
    "paths": [".dotnet", "$host$"]
  4. From the repo root, run dotnet --version -> 10.0.103 (correct, resolves from .dotnet)
  5. Run dotnet --list-sdks -> shows SDKs from both .dotnet and /usr/local/share/dotnet (correct)
  6. Run dotnet --list-runtimes -> only shows 10.0.3 from /usr/local/share/dotnet -- the 8.0.21 and 9.0.10 runtimes in .dotnet are missing
  7. Running a test project targeting net8.0 via the VS Code Test Explorer fails:
    You must install or update .NET to run this application.
    
    App: .../artifacts/bin/Aspire.Hosting.DotnetTool.Tests/Debug/net8.0/Aspire.Hosting.DotnetTool.Tests
    Architecture: arm64
    Framework: 'Microsoft.NETCore.App', version '8.0.0' (arm64)
    .NET location: /usr/local/share/dotnet
    
    The following frameworks were found:
      10.0.3 at [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
    

Expected Behavior

When running tests from the VS Code Test Explorer (or via terminal), runtimes installed in the paths directories from global.json should be discoverable, so that test projects targeting net8.0/net9.0 can execute without manually setting DOTNET_ROOT.

Actual Behavior

Only runtimes from the host's own install location (/usr/local/share/dotnet) are found. The paths feature affects SDK resolution but not runtime resolution when tests are launched.

Workaround

Launch VS Code using the repo's start-code.sh script, which sets DOTNET_ROOT and PATH to point to the local .dotnet directory. Alternatively, manually set:

export DOTNET_ROOT=/path/to/repo/.dotnet
export PATH=$DOTNET_ROOT:$PATH

Environment

  • macOS 14.8, arm64
  • VS Code (latest)
  • System .NET: 10.0.3 at /usr/local/share/dotnet
  • Local .dotnet: SDK 10.0.103, runtimes 8.0.21, 9.0.10, 10.0.3
  • global.json paths: [".dotnet", "$host$"]
  • Repository: dotnet/aspire

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions