-
Notifications
You must be signed in to change notification settings - Fork 407
Fix SDK installation suggestion for already-installed versions #9834
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
Merged
+1,433
−102
Conversation
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
Previously, the project retargeting handler would suggest installing an SDK version that was already installed on the system. This occurred because the check for installed SDKs was not properly implemented. Changes: - Add SdkInstallationService to detect globally installed .NET SDKs by querying the Windows registry for both 32-bit and 64-bit SDK installations - Add IRegistry abstraction and RegistryService implementation for testable registry access - Update ProjectRetargetHandler to check if the retarget SDK version is already installed before suggesting installation - Add IEnvironment abstraction and EnvironmentService for testable environment variable access - Add comprehensive unit tests for SdkInstallationService, RegistryService, and EnvironmentService - Simplify IRegistryMock test helper to use string-based keys instead of complex tuple structures - Fix JsonDocument.Parse to use ParseAsync for proper async/await pattern in ProjectRetargetHandler
drewnoakes
reviewed
Oct 22, 2025
...icrosoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/Utilities/RegistryService.cs
Outdated
Show resolved
Hide resolved
...icrosoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/Utilities/RegistryService.cs
Outdated
Show resolved
Hide resolved
...isualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/Retargeting/ISdkInstallationService.cs
Outdated
Show resolved
Hide resolved
...isualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/Retargeting/ISdkInstallationService.cs
Outdated
Show resolved
Hide resolved
...VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/Retargeting/SdkInstallationService.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.VisualStudio.ProjectSystem.Managed/ProjectSystem/Utilities/IEnvironment.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.VisualStudio.ProjectSystem.Managed/ProjectSystem/Utilities/IEnvironment.cs
Outdated
Show resolved
Hide resolved
...s/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/Mocks/Utilities/IEnvironmentMock.cs
Outdated
Show resolved
Hide resolved
...s/Microsoft.VisualStudio.ProjectSystem.Managed.VS.UnitTests/Mocks/Utilities/IRegistryMock.cs
Outdated
Show resolved
Hide resolved
...ojectSystem.Managed.VS.UnitTests/ProjectSystem/VS/Retargeting/ProjectRetargetHandlerTests.cs
Outdated
Show resolved
Hide resolved
drewnoakes
reviewed
Oct 22, 2025
...VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/Retargeting/SdkInstallationService.cs
Outdated
Show resolved
Hide resolved
drewnoakes
reviewed
Oct 22, 2025
...VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/Retargeting/SdkInstallationService.cs
Outdated
Show resolved
Hide resolved
Replace CLI-based SDK detection with direct Windows registry queries for improved
performance and reliability.
Key changes:
- Create IDotNetEnvironment service to centralize .NET environment queries
- Check installed SDK versions via registry (SOFTWARE\dotnet\Setup\InstalledVersions\{arch}\sdk)
- Detect .NET runtime versions via registry
- Locate dotnet.exe host path with registry fallback to Program Files
- Refactor SetupComponentRegistrationService to use IDotNetEnvironment instead of
NetCoreRuntimeVersionsRegistryReader
- Add ExceptionExtensions.IsCatchable() for safer exception handling
This eliminates the need to spawn dotnet.exe processes for SDK detection
drewnoakes
approved these changes
Oct 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really nicely structured change. I like where this landed, and the test quality is chefs kiss :)
A few small comments but nothing major.
src/Microsoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/Setup/DotNetEnvironment.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/Setup/DotNetEnvironment.cs
Outdated
Show resolved
Hide resolved
...Microsoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/Setup/IDotNetEnvironment.cs
Outdated
Show resolved
Hide resolved
...Microsoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/Setup/IDotNetEnvironment.cs
Outdated
Show resolved
Hide resolved
...soft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/Utilities/ExceptionExtensions.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.VisualStudio.ProjectSystem.Managed/ProjectSystem/Utilities/IEnvironment.cs
Show resolved
Hide resolved
src/Microsoft.VisualStudio.ProjectSystem.Managed/ProjectSystem/Utilities/IEnvironment.cs
Outdated
Show resolved
Hide resolved
* merged IEnvironmentHelper into IEnvironment * change IsSdkInstalledAsync to IsSdkInstalled * removed unneeded Is64BitOperatingSystem * Moved ExceptionExtensions to non-VS assembly, fixed namespace
LittleLittleCloud
approved these changes
Oct 23, 2025
|
/backport to dev18.0.x |
|
Started backporting to dev18.0.x: https://github.com/dotnet/project-system/actions/runs/18753332222 |
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.
Previously, the project retargeting handler would suggest installing an SDK version that was already installed on the system. This occurred because the check for installed SDKs was not properly implemented.
Changes: