Skip to content

Improve dotnet resolution when using multiple dotnet SDKs - #2

Open
jelenv wants to merge 2 commits into
kevin-mueller:feature/razor-and-morefrom
jelenv:dev/dotnet-dual-sdk-resolution-pr
Open

Improve dotnet resolution when using multiple dotnet SDKs#2
jelenv wants to merge 2 commits into
kevin-mueller:feature/razor-and-morefrom
jelenv:dev/dotnet-dual-sdk-resolution-pr

Conversation

@jelenv

@jelenv jelenv commented Mar 24, 2026

Copy link
Copy Markdown

Why

This change makes the extension more reliable for mixed dotnet SDK setups (for example .NET 10
primary and .NET 8 for older repos).

In my setup I have dotnet 10 and 8 installed via mise on linux and without these changes, I was not able to use the extension, because it was trying to use incorrect dotnet SDKs.

What changed

  • Unified dotnet context selection so these paths stay aligned:
    • SDK lookup
    • DOTNET_ROOT detection
    • roslyn-language-server tool install/update
    • Razor extension build
  • Kept default behavior global/system oriented for broad compatibility
  • DOTNET_ROOT now comes from dotnet --info and successful global lookups are cached
  • Improved diagnostics: failed tool install/update and Razor build now return stdout/stderr (helps with extension troubleshooting).
  • Added optional use_worktree_dotnet_env setting so dotnet commands can run in the worktree shell environment when explicitly enabled.

Disclaimer

I am not experienced with Rust, let me know if there is any slop or something to improve.

jelenv added 2 commits March 24, 2026 13:36
Motivation: support mixed SDK setups reliably, such as .NET 10 primary with .NET 8 for older repositories, without coupling behavior to one SDK manager.\n\nChanges:\n- Add optional setting use_worktree_dotnet_env to run dotnet commands with worktree shell environment when explicitly enabled.\n- Align SDK lookup, runtime root detection, tool install/update, and Razor build to the same selected dotnet context.\n- Keep default behavior global and manager-agnostic; detect DOTNET_ROOT from dotnet info and cache successful global lookups.\n- Return stdout/stderr for failed tool install/update and Razor build to improve diagnosability.\n- Remove duplicated command construction paths via a shared optional-environment helper.
Align SDK path selection with list-sdks output by parsing installed SDK entries and selecting the latest listed entry. This keeps Razor compiler/targets lookup tied to the newest installed SDK in the selected dotnet environment.
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