Automatically acquire the .NET 10 runtime via the .NET Install Tool#884
Merged
Merged
Conversation
Builds on #879 (graceful handling of a missing runtime). Instead of only detecting a missing runtime and prompting the user to install it manually, the extension now downloads a compatible net10.0 runtime on demand via the .NET Install Tool's dotnet.acquire API, mirroring the official C# extension's DotnetRuntimeExtensionResolver. dotnetResolver.ts resolution order: 1. Compatible dotnet already on PATH. 2. Existing runtime located via dotnet.findPath (>=, rejectPreviews). 3. Runtime downloaded on demand via dotnet.acquireStatus/acquire (mode runtime, version 10.0), with dotnet.ensureDotnetDependencies on Linux. 4. DotnetRuntimeMissingError only when acquisition cannot complete. resolveDotnetRuntime now returns { dotnetPath, env } and pins the server to the resolved runtime via DOTNET_ROOT / DOTNET_MULTILEVEL_LOOKUP. serverManager merges that env overlay; the missing-runtime prompt is now a last resort. Adds jest coverage for the PATH / findPath / acquire / error paths and updates the README requirement wording and CHANGELOG.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
PR #879 made the extension fail gracefully when the bundled
net10.0language server has no compatible runtime to host it: instead of a crash-toast cascade, it detects the missing runtime (via PATH anddotnet.findPath) and shows a single "Install .NET" prompt. But the user still has to go install .NET 10 by hand before the LSP works.We already take an
extensionDependencyon the .NET Install Tool (ms-dotnettools.vscode-dotnet-runtime), so we can do better and just acquire the runtime for them — the same thing the C# extension does.Change
resolveDotnetRuntimenow downloads a compatible runtime on demand, mirroring vscode-csharp'sDotnetRuntimeExtensionResolver.New resolution order:
dotnetalready on PATH exposing aMicrosoft.NETCore.App>= 10 (no Install Tool round-trip).dotnet.findPath(greater_than_or_equal,rejectPreviews).dotnet.acquireStatus->dotnet.showAcquisitionLog->dotnet.acquire(mode: runtime,version: 10.0);dotnet.ensureDotnetDependenciesis invoked on Linux.DotnetRuntimeMissingErroronly when acquisition truly cannot complete (e.g. offline with nothing cached or the Install Tool unavailable).resolveDotnetRuntimenow returns{ dotnetPath, env }and pins the host to the resolved/acquired runtime viaDOTNET_ROOT/DOTNET_MULTILEVEL_LOOKUP(same as the C# extension), so the server cannot roll forward/back onto a different runtime.serverManagermerges that env overlay and the "Install .NET" prompt becomes a last resort, with updated wording noting that automatic acquisition was attempted first.Tests
dotnetRuntimeAcquire.test.tscovering the PATH fast path, thefindPathhit, theacquirefallback (assertingDOTNET_ROOTpinning and thedotnet.acquirecall), and both error paths (Install Tool unavailable / acquisition yields nothing).Verification
npm run test:unit-> 13 passednpm run lint-> cleantsc --noEmit-> cleannpm run compile(esbuild + server build) -> succeedsDocs