8000 Use local SDK in global.json by Youssef1313 · Pull Request #5671 · microsoft/testfx · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Use local SDK in global.json #5671

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

Use local SDK in global.json #5671

wants to merge 4 commits into from

Conversation

Youssef1313
Copy link
Member
@Youssef1313 Youssef1313 commented May 30, 2025

@@ -24,6 +24,7 @@
},
"sdk": {
"version": "10.0.100-preview.5.25269.23",
"paths": [ ".dotnet", "$host$" ],
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm seeing the following in CI:

2025-05-30T07:58:27.6583168Z D:\a\_work\1\s\artifacts\bin\MSTest.Acceptance.IntegrationTests\Release\net10.0\MSTest.Acceptance.IntegrationTests.exe (net10.0|) failed (0ms)
2025-05-30T07:58:27.6588369Z Exit code: -2147450730
2025-05-30T07:58:27.6589476Z   Error output: You must install or update .NET to run this application.
2025-05-30T07:58:27.6590320Z   App: D:\a\_work\1\s\artifacts\bin\MSTest.Acceptance.IntegrationTests\Release\net10.0\MSTest.Acceptance.IntegrationTests.exe
2025-05-30T07:58:27.6590869Z   Architecture: x64
2025-05-30T07:58:27.6591348Z   Framework: 'Microsoft.NETCore.App', version '10.0.0-preview.5.25265.101' (x64)
2025-05-30T07:58:27.6591829Z   .NET location: C:\Program Files\dotnet\
2025-05-30T07:58:27.6592256Z   The following frameworks were found:
2025-05-30T07:58:27.6593235Z     6.0.36 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
2025-05-30T07:58:27.6593725Z     6.0.37 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
2025-05-30T07:58:27.6594218Z     8.0.13 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
2025-05-30T07:58:27.6594690Z     9.0.2 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
2025-05-30T07:58:27.6595105Z   Learn more:
2025-05-30T07:58:27.6595531Z   https://aka.ms/dotnet/app-launch-failed
2025-05-30T07:58:27.6595993Z   To install missing framework, download:
2025-05-30T07:5
10000
8:27.6596537Z   https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=10.0.0-preview.5.25265.101&arch=x64&rid=win-x64&os=win10

This is kinda unexpected for me.

Copy link
Member Author
@Youssef1313 Youssef1313 May 30, 2025

Choose a reason for hiding this comment

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

@jaredpar Is there any additional work needed on SDK side for dotnet test?

We simply just run the test executable in dotnet test here (and a parent directory of the executable has global.json pointing to the locally installed SDK).

Copy link
Member Author
@Youssef1313 Youssef1313 May 30, 2025

Choose a reason for hiding this comment

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

Running locally:

image

  • dotnet --list-sdks: Recognizes the SDK from global.json
  • dotnet --list-runtimes: Doesn't recognize runtimes from the locally installed SDK
  • .dotnet/dotnet.exe --list-runtimes: Recognizes runtimes from the locally installed SDK

Not sure if this is by-design or if there is something missing with the local SDK feature, and if it's by-design, how can we improve the experience there for dotnet test at least (if we should do anything at all)

Copy link
Member

Choose a reason for hiding this comment

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

I would start from corehost_trace=1 to understand what is happening. Typically I see dotnet_root set to define where the local dotnets are, dotnet_multilevel_lookup set to 0 to prevent going to global dotnet installation (program files), and then also .dotnet.dotnet.exe being added to PATH to ensure we resolve the local dotnet exe for SDK builds.

Copy link
Member Author

Choose a reason for hiding this comment

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

Nothing is interesting in the trace logs it seems :(

Using dotnet root path [C:\Program Files\dotnet]

It's not considering the local SDK at all. I'm not sure if that's intended.

Copy link
Member Author

Choose a reason for hiding this comment

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

https://github.com/dotnet/designs/blob/main/accepted/2025/local-sdk-global-json.md#dotnet-exec:

This proposal only impacts how .NET SDK commands do runtime discovery. The command dotnet exec is not an .NET SDK command but instead a way to invoke the app directly using the runtime installed with dotnet.

It is reasonable for complex builds to build and use small tools. For example building a tool for linting the build, running complex validation, etc ... To work with local SDK discovery these builds need to leverage dotnet run to execute such tools instead of dotnet exec.

Looks like probably by-design? 😕

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Correct, by design. This is an SDK feature, not a runtime feature. If you run “app.exe” it will not look for a global.json.

Copy link
Member Author
@Youssef1313 Youssef1313 May 30, 2025

Choose a reason for hiding this comment

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

So, from user point of view, they are invoking dotnet test, so it's SDK. But as SDK currently simply runs the test executable directly, we hit this issue (in simple words, we are moving from SDK-world to runtime but losing the info about runtimes installed in the local SDK).

So I guess there might be something to do for the implementation of dotnet test in that regard? What exactly should we do for dotnet test?

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.

4 participants
0