Skip to content

Use the resolved dotnet executable for SDK discovery - #761

Merged
Andy Gerlicher (AndyGerlicher) merged 1 commit into
microsoft:mainfrom
stan-sz:fix/resolved-dotnet-executable
Nov 16, 2026
Merged

Andy Gerlicher (AndyGerlicher) merged 1 commit into
microsoft:mainfrom
stan-sz:fix/resolved-dotnet-executable

Conversation

@stan-sz

@stan-sz stan-sz commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Use the full path of the already-resolved dotnet executable when launching SDK discovery.

Problem

The relevant issue summary is:

SDK discovery launched dotnet by name, which could resolve to a different executable than the one already located.

Although TryResolveDotNetCoreSdk receives the located executable as a FileInfo, the discovery process used the bare name dotnet. That allowed process lookup to select an executable from PATH instead, potentially interrogating a different installation.

Fix

Set ProcessStartInfo.FileName to dotnetFileInfo.FullName. Keep the --info invocation, working directory, output redirection, and other process settings unchanged.

Regression test

Add DotNetCoreSdkResolverTests.TryResolveDotNetCoreSdk_DoesNotFallBackToDotNetOnPath:

  • Supply a nonexistent resolved executable under the test directory.
  • Verify SDK resolution returns false.
  • Verify the returned development environment is unsuccessful.

The test runs in an environment where dotnet is available on PATH, ensuring a missing resolved executable does not silently succeed by falling back to that installation.

Validation

Built and tested this branch independently on Windows, targeting .NET 10:

dotnet test .\src\Microsoft.VisualStudio.SlnGen.UnitTests\Microsoft.VisualStudio.SlnGen.UnitTests.csproj --framework net10.0 --no-restore --filter "FullyQualifiedName~DotNetCoreSdkResolverTests" --verbosity minimal

Result: 1 passed, 0 failed, 0 skipped; build completed with 0 warnings and 0 errors.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@AndyGerlicher
Andy Gerlicher (AndyGerlicher) merged commit 0125dfc into microsoft:main Nov 16, 2026
3 checks passed
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.

2 participants