tintoy / msbuild-project-tools-vscode

VS Code extension for MSBuild intellisense (including PackageReference completion).
MIT License
82 stars 16 forks source link

Use .NET Runtime from the host when possible #145

Closed DoctorKrolic closed 3 months ago

DoctorKrolic commented 3 months ago

Related to https://github.com/tintoy/msbuild-project-tools-vscode/issues/144

DoctorKrolic commented 3 months ago

Tested on my PC with .NET 9 preview installed, and I can confirm, that this PR still needs work in 2 main points:

  1. dotnet --version returns version of a latest SDK, not the runtime. So we actually need to parse result of dotnet --list-runtimes and pick up the latest one
  2. If there are multiple version available, dotnet will pick up the closest available one. So e.g. I have both .NET 8 and .NET 9 preview installed and if I just use host dotnet it picks up .NET 8 runtime, making all effort of using host dotnet somewhat unnecessary. So we need to use --fx-version to force it to use the latest version of dotnet available on the PC
DoctorKrolic commented 3 months ago

@tintoy After looking at this again, I changed my mind a bit. I think, it is actually too unsafe to just grab the most recent runtime user have installed. I would say, this should be a conscious choice os the user rather than the default behavior. However, this PR still has a value of its own: now if user has appropriate runtime, the extension will pick it up instead of downloading an isolated one. I think, we can merge this and work on server reloading with newer version of the runtime later.

tintoy commented 3 months ago

I would say, this should be a conscious choice os the user rather than the default behavior

Yeah - I’m a big fan of opt-in for newer behaviour (whether ours or that of a downstream dependency) so definitely agree 🙂