tintoy / msbuild-project-tools-vscode

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

Extension fails with error: "Cannot locate MSBuild engine for .NET SDK v9.0.100." #149

Closed djohnst10 closed 6 days ago

djohnst10 commented 1 month ago

With the .NET 9 SDK Preview 4 installed I get these errors in VS Code when opening a folder containing a .NET solution.

System.Exception: Cannot locate MSBuild engine for .NET SDK v9.0.100. This probably means that MSBuild Project Tools cannot find the MSBuild for the current project instance. It did find the following version(s), though: [8.0.300].
   at MSBuildProjectTools.LanguageServer.Utilities.MSBuildHelper.DiscoverMSBuildEngine(String baseDirectory, ILogger logger)
   at MSBuildProjectTools.LanguageServer.Program.Main()
[Error - 10:41:51 AM] Connection to server got closed. Server will not be restarted.
[Error - 10:41:51 AM] MSBuild Language Service client: couldn't create connection to server.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 10:41:51 AM] Server process exited with code 1.

The .NET solution I usually work on has a mix of .NET Standard projects and older .NET Framework projects, but I've got these errors with folders containing only .NET SDK-style projects.

Here are the .NET SDKs installed: 8.0.300 [C:\Program Files\dotnet\sdk] 9.0.100-preview.4.24267.66 [C:\Program Files\dotnet\sdk]

tintoy commented 1 month ago

Hi - sorry to hear you're having problems; are you able to post the full output from running dotnet --info in the solution directory?

tintoy commented 1 month ago

I'm pretty sure this is related to tintoy/msbuild-project-tools-vscode#144; the mechanism we use to locate the appropriate MSBuild version for the current runtime (MSBuildLocator) has not, historically, supported preview versions of .NET and simply ignored them). It does support preview versions now, but we have to opt into supporting them and we haven't decided (yet) how best to do that.

@DoctorKrolic - can I get a second opinion / sanity check? 🙂

djohnst10 commented 1 month ago

Here is the log.

I looked at #144. This does look like the same issue.

.NET SDK:
 Version:           9.0.100-preview.4.24267.66
 Commit:            26d3d259e4
 Workload version:  9.0.100-manifests.9dc03b27
 MSBuild version:   17.11.0-preview-24225-01+bd0b1e466

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22631
 OS Platform: Windows
 RID:         win-x64
 Base Path:   C:\Program Files\dotnet\sdk\9.0.100-preview.4.24267.66\

.NET workloads installed:
 [maui-windows]
   Installation Source: VS 17.10.34916.146, VS 17.11.34909.67
   Manifest Version:    9.0.0-preview.1.9973/9.0.100-preview.1
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\9.0.100-preview.1\microsoft.net.sdk.maui\9.0.0-preview.1.9973\WorkloadManifest.json
   Install Type:              Msi

 [maccatalyst]
   Installation Source: VS 17.10.34916.146, VS 17.11.34909.67
   Manifest Version:    17.2.9088-net9-p1/9.0.100-preview.1
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\9.0.100-preview.1\microsoft.net.sdk.maccatalyst\17.2.9088-net9-p1\WorkloadManifest.json
   Install Type:              Msi

 [ios]
   Installation Source: VS 17.10.34916.146, VS 17.11.34909.67
   Manifest Version:    17.2.9088-net9-p1/9.0.100-preview.1
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\9.0.100-preview.1\microsoft.net.sdk.ios\17.2.9088-net9-p1\WorkloadManifest.json
   Install Type:              Msi

 [android]
   Installation Source: VS 17.10.34916.146, VS 17.11.34909.67
   Manifest Version:    34.99.0-preview.1.151/9.0.100-preview.1
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\9.0.100-preview.1\microsoft.net.sdk.android\34.99.0-preview.1.151\WorkloadManifest.json
   Install Type:              Msi

 [aspire]
   Installation Source: VS 17.10.34916.146, VS 17.11.34909.67
   Manifest Version:    9.0.0-preview.2.24163.9/9.0.100-preview.1
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\9.0.100-preview.1\microsoft.net.sdk.aspire\9.0.0-preview.2.24163.9\WorkloadManifest.json
   Install Type:              Msi

Host:
  Version:      9.0.0-preview.4.24266.19
  Architecture: x64
  Commit:       d0d6fed6c0

.NET SDKs installed:
  8.0.300 [C:\Program Files\dotnet\sdk]
  9.0.100-preview.4.24267.66 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 8.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 9.0.0-preview.4.24267.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.30 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 9.0.0-preview.4.24266.19 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 6.0.30 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 8.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 9.0.0-preview.4.24267.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  x86   [C:\Program Files (x86)\dotnet]
    registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
  Not set

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download