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
- Have a system-wide .NET install at
/usr/local/share/dotnet with only .NET 10.0.3
- 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
global.json has:
"paths": [".dotnet", "$host$"]
- From the repo root, run
dotnet --version -> 10.0.103 (correct, resolves from .dotnet)
- Run
dotnet --list-sdks -> shows SDKs from both .dotnet and /usr/local/share/dotnet (correct)
- 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
- 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
Description
The
global.jsonpathsproperty (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 ordotnet --list-runtimes.This affects repos like dotnet/aspire where
restore.shinstalls multiple .NET runtimes (8.0, 9.0, 10.0) into a local.dotnetdirectory andglobal.jsonuses"paths": [".dotnet", "$host$"]to point to them.Reproduction
/usr/local/share/dotnetwith only .NET 10.0.3restore.shwhich installs .NET 8.0.21, 9.0.10, and SDK 10.0.103 into a local.dotnetdirectoryglobal.jsonhas:dotnet --version-> 10.0.103 (correct, resolves from.dotnet)dotnet --list-sdks-> shows SDKs from both.dotnetand/usr/local/share/dotnet(correct)dotnet --list-runtimes-> only shows 10.0.3 from/usr/local/share/dotnet-- the 8.0.21 and 9.0.10 runtimes in.dotnetare missingnet8.0via the VS Code Test Explorer fails:Expected Behavior
When running tests from the VS Code Test Explorer (or via terminal), runtimes installed in the
pathsdirectories fromglobal.jsonshould be discoverable, so that test projects targeting net8.0/net9.0 can execute without manually settingDOTNET_ROOT.Actual Behavior
Only runtimes from the host's own install location (
/usr/local/share/dotnet) are found. Thepathsfeature affects SDK resolution but not runtime resolution when tests are launched.Workaround
Launch VS Code using the repo's
start-code.shscript, which setsDOTNET_ROOTandPATHto point to the local.dotnetdirectory. Alternatively, manually set:Environment
/usr/local/share/dotnet.dotnet: SDK 10.0.103, runtimes 8.0.21, 9.0.10, 10.0.3global.jsonpaths:[".dotnet", "$host$"]