tintoy / msbuild-project-tools-vscode

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

Unable to parse output from `dotnet --info` and activate the extension #98

Closed baronfel closed 1 year ago

baronfel commented 2 years ago

With version 0.4.3 of this extension, I can't seem to get the extension to activate. The VSCode extension host logs say the following:

 Error: Failed to find the Host version information in output from "dotnet --info".
    at Object.<anonymous> (c:\Users\chusk\.vscode\extensions\tintoy.msbuild-project-tools-0.4.3\out\src\extension\utils\dotnet.js:72:19)
    at Generator.next (<anonymous>)
    at fulfilled (c:\Users\chusk\.vscode\extensions\tintoy.msbuild-project-tools-0.4.3\out\src\extension\utils\dotnet.js:5:58)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

, and when I dig into this a bit, I think the root cause is because the shape of dotnet --info has changed. Here's my output:

❯ dotnet --info
.NET SDK (reflecting any global.json):
 Version:   6.0.201
 Commit:    ef40e6aa06

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22000
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\6.0.201\

global.json file:
  D:\Code\Ionide.KeepAChangelog\global.json

Host:
  Version:      7.0.0-preview.4.22201.3
  Architecture: x64
  Commit:       c3e44952bb

.NET SDKs installed:
  3.1.417 [C:\Program Files\dotnet\sdk]
  5.0.212 [C:\Program Files\dotnet\sdk]
  5.0.303 [C:\Program Files\dotnet\sdk]
  5.0.402 [C:\Program Files\dotnet\sdk]
  5.0.406 [C:\Program Files\dotnet\sdk]
  6.0.101 [C:\Program Files\dotnet\sdk]
  6.0.201 [C:\Program Files\dotnet\sdk]
  6.0.300-preview.22128.2 [C:\Program Files\dotnet\sdk]
  7.0.100-preview.4.22204.1 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 3.1.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.23 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.0-preview.4.22201.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.23 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.0-rc.2.21480.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.0-preview.4.22201.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.20 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.23 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.15 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.0-rc.2.21501.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.0-preview.4.22181.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

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

Learn about .NET Runtimes and SDKs:
  https://aka.ms/dotnet/runtimes-sdk-info

The big difference here is that there's a section called global.json file in the output that I don't think the code knows about.

More broadly, though, why is the version of the host specifically interesting? If the idea is just to check for a minimum 5.0 version, why not use the output of dotnet --version instead:

❯ dotnet --version
6.0.201

I think this would be much more stable. This is what we do in Ionide for similar purposes.

tintoy commented 2 years ago

Hi - the real problem is that the extension needs to know about SDK versions and locations (to detect when the language server won’t load due to incompatible runtime) and dotnet.exe doesn’t provide a machine-parseable output format (the language server has to do the same thing in some cases but is at least helped by the MSBuildLocator library these days). Should be easy enough to fix though :)

glektarssza commented 1 year ago

Opened #102 to address this issue temporarily.

tintoy commented 1 year ago

This should be working correctly now as of v0.4.6 (just published it to the gallery).

I'm hoping the new mechanism being used to discover .NET SDK information should be a little more robust/future-proof 🙂