Skip to content

Clear error instead of crash when no compatible .NET SDK is installed - #531

Merged
waf merged 2 commits into
mainfrom
fix-526-missing-compatible-sdk
Nov 28, 2026
Merged

waf merged 2 commits into
mainfrom
fix-526-missing-compatible-sdk

Conversation

@waf

@waf waf commented Nov 28, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Fixes Nuget error when the only installed sdk is .net 11 rc #526. NuGet assemblies load from the installed .NET SDK via MSBuildLocator, which ignores SDKs newer than the runtime csharprepl runs on. With only a preview SDK of the next major .NET installed, nothing gets registered, and the eagerly constructed NugetPackageInstaller crashed the REPL on the first keypress with FileNotFoundException: NuGet.Versioning.
  • The installer is now created lazily, and #r "nuget:" reports which .NET SDK to install when none was registered. A code comment records DOTNET_ROLL_FORWARD_TO_PRERELEASE=1 as a possible, untested user mitigation.

Verified with a fake dotnet root that has the 11.0 runtime and only a "12.0.100-preview" SDK: main crashes even on 1+1; this branch evaluates plain C# and gives the new message for NuGet references.

…exists

NuGet and MSBuild assemblies are loaded from the installed .NET SDK via
MSBuildLocator, which ignores SDKs newer than the running runtime. With only
a preview SDK of the next major .NET installed, nothing is registered, and
the eagerly constructed NugetPackageInstaller crashed the REPL on the first
keypress with a FileNotFoundException for NuGet.Versioning (#526).

The NuGet installer is now created lazily. NuGet and project/solution
references report which SDK to install, and deps.json expansion is skipped,
so plain C# evaluation keeps working.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.4%. Comparing base (ee45fad) to head (3459135).

Files with missing lines Patch % Lines
.../MetadataResolvers/NugetPackageMetadataResolver.cs 50.0% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main    #531     +/-   ##
=======================================
- Coverage   80.5%   80.4%   -0.1%     
=======================================
  Files        130     130             
  Lines       9503    9506      +3     
  Branches    1432    1433      +1     
=======================================
  Hits        7652    7652             
- Misses      1358    1360      +2     
- Partials     493     494      +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Drop the DotNetSdkRequirement class, its tests, and the project-reference and
deps.json guards. The crash only needed the NuGet installer to be created
lazily, plus a clear error on #r "nuget:" when no SDK was registered.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@waf
waf merged commit 7dc0dcc into main Nov 28, 2026
3 checks passed
@waf
waf deleted the fix-526-missing-compatible-sdk branch November 28, 2026 03:22
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.

Nuget error when the only installed sdk is .net 11 rc

1 participant