tintoy / msbuild-project-tools-vscode

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

Add support for VSCode Remote scenarios #99

Closed tintoy closed 1 year ago

tintoy commented 2 years ago

See https://code.visualstudio.com/api/advanced-topics/remote-extensions and https://code.visualstudio.com/api/advanced-topics/extension-host for details

tintoy commented 2 years ago

Published v0.4.4 of MSBuild Project Tools extension to the gallery.

@geniuskamo - here is the Codespace-enabled repository I've been testing with: https://github.com/tintoy/msbuild-project-tools-codespace-demo

geniuskamo commented 1 year ago

Thank you @tintoy

geniuskamo commented 1 year ago

Published v0.4.4 of MSBuild Project Tools extension to the gallery.

@geniuskamo - here is the Codespace-enabled repository I've been testing with: https://github.com/tintoy/msbuild-project-tools-codespace-demo

How do I use this ?

loligans commented 1 year ago

I'm also trying to run this, I'm using v0.4.5 inside a Dev Container. The language server doesn't appear to be working for me

loligans commented 1 year ago

image This is what I see inside the dev tools

tintoy commented 1 year ago

Are you on the latest version of the extension?

There is a setting to turn up the log level for MSBuild Project Tools - can you try setting that to “Verbose” and trying again?

tintoy commented 1 year ago

https://github.com/tintoy/msbuild-project-tools-vscode/blob/ea103edde90bb0c667a4d663ee2cf47f079bb3c3/package.json#L53

loligans commented 1 year ago

I tried setting the logging level to verbose for the devcontainer.json and also the .vscode settings.json. It did not give any additional output other than what I screenshotted above. I am connecting to the dev container using VSCode's built in ssh client if that matters

loligans commented 1 year ago

image

tintoy commented 1 year ago

Hmm - I can’t say I’ve seen that one before. I’ll have a look tonight after work and see if I can reproduce the problem.

Just out of curiosity, what is the output of dotnet --info when run in that container?

loligans commented 1 year ago

The extension is executing within the container. My VSCode instance on the laptop is connecting to that container.

From Container

``` .NET SDK (reflecting any global.json): Version: 6.0.301 Commit: 43f9b18481 Runtime Environment: OS Name: debian OS Version: 11 OS Platform: Linux RID: debian.11-x64 Base Path: /usr/share/dotnet/sdk/6.0.301/ Host (useful for support): Version: 6.0.6 Commit: 7cca709db2 .NET SDKs installed: 6.0.301 [/usr/share/dotnet/sdk] .NET runtimes installed: Microsoft.AspNetCore.App 6.0.6 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 6.0.6 [/usr/share/dotnet/shared/Microsoft.NETCore.App] To install additional .NET runtimes or SDKs: https://aka.ms/dotnet-download ```

From Container Host

``` .NET SDK (reflecting any global.json): Version: 6.0.106 Commit: 4f1e0330de Runtime Environment: OS Name: arch OS Version: OS Platform: Linux RID: arch-x64 Base Path: /usr/share/dotnet/sdk/6.0.106/ Host (useful for support): Version: 6.0.6 Commit: 7cca709db2 .NET SDKs installed: 6.0.106 [/usr/share/dotnet/sdk] .NET runtimes installed: Microsoft.AspNetCore.App 6.0.6 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 6.0.6 [/usr/share/dotnet/shared/Microsoft.NETCore.App] To install additional .NET runtimes or SDKs: https://aka.ms/dotnet-download ```

From Host (my laptop)

``` .NET SDK (reflecting any global.json): Version: 6.0.107 Commit: f6ec7508e3 Runtime Environment: OS Name: arch OS Version: OS Platform: Linux RID: arch-x64 Base Path: /usr/share/dotnet/sdk/6.0.107/ global.json file: Not found Host: Version: 6.0.7 Architecture: x64 Commit: 0ec02c8c96 .NET SDKs installed: 6.0.107 [/usr/share/dotnet/sdk] .NET runtimes installed: Microsoft.NETCore.App 6.0.7 [/usr/share/dotnet/shared/Microsoft.NETCore.App] Download .NET: https://aka.ms/dotnet-download Learn about .NET Runtimes and SDKs: https://aka.ms/dotnet/runtimes-sdk-info ```

tintoy commented 1 year ago

Sorry, one last question - what version of the extension is VSCode showing (both local and remote)?

loligans commented 1 year ago

Both local and remote have v0.4.5 installed

tintoy commented 1 year ago

Ok - it looks like it’s failing because there is no global.json section in the output (because the section names are localised, we have to count them in order to find the one we want). Interestingly, the output from your local machine does include this section but the container does not.

If you add a global.json file to the solution directory you’re accessing in the container, does the output then include that section?

I’m trying to work out whether we have to somehow guess if that section is present or not…

tintoy commented 1 year ago

Ok, it looks like they finally added support for directly listing SDKs and runtime versions:

https://docs.microsoft.com/en-us/dotnet/core/install/how-to-detect-installed-versions?pivots=os-windows#check-sdk-versions

I’ll have a go at switching over to using this instead of parsing the output of dotnet --info (previously, this was the only way to discover SDK versions and their containing directories)…

loligans commented 1 year ago

If you create a pre-release I could test your change in my container

tintoy commented 1 year ago

Sure no problem - will let you know as soon as I have something to test 🙂

tintoy commented 1 year ago

Sorry, am still working on this - work has been a little hectic this week 🙂

Should be ready soon.

tintoy commented 1 year ago

@loligans - can you try this build? I think the extension should now have a better chance at handling various forms of output from the dotnet command-line tool, but the .NET-side code in the language server itself may still have issues.

loligans commented 1 year ago

Yes, how can I install it into my container? I don't see a new version when I choose "Install Another Version" in the extension settings

loligans commented 1 year ago

I tried going back to v0.4.4 and the language server works again. I will still try your build when it becomes available :)

tintoy commented 1 year ago

Sorry, it's been a long day - I meant to upload the package as an attachment to that comment 😂

msbuild-project-tools-0.4.6-dev.zip

You may need to explicitly uninstall the extension version from the marketplace before you install from the VSIX package (Extensions -> Install from VSIX) and, afterwards, you can do the reverse to go back to automatic updates.

loligans commented 1 year ago

Haha no problem! I just tested your fix and its working!

tintoy commented 1 year ago

Great - thanks for testing! I’ll make sure nothing else is broken and then publish a new version of the extension to the gallery.

tintoy commented 1 year ago

Published v0.4.6 of the extension to the gallery (the .NET-side language server implementation is also more robust now).

loligans commented 1 year ago

Latest version running in the container gives me this exception:

Starting MSBuild language service...
Failed to start the MSBuild language server.
Error: Command failed: "/usr/bin/dotnet" "/home/loligans/.vscode-server/extensions/tintoy.msbuild-project-tools-0.4.6/out/language-server/MSBuildProjectTools.LanguageServer.Host.dll" --probe
System.ArgumentException: '' is not a valid version string. (Parameter 'value')
   at NuGet.Versioning.SemanticVersion.Parse(String value)
   at MSBuildProjectTools.LanguageServer.Utilities.DotNetRuntimeInfo.ParseDotNetVersionOutput(TextReader dotnetVersionOutput) in D:\Development\github\tintoy\msbuild-project-tools-vscode\lib\server\src\LanguageServer.Common\Utilities\DotNetRuntimeInfo.cs:line 140
   at MSBuildProjectTools.LanguageServer.Utilities.DotNetRuntimeInfo.GetCurrent(String baseDirectory, ILogger logger) in D:\Development\github\tintoy\msbuild-project-tools-vscode\lib\server\src\LanguageServer.Common\Utilities\DotNetRuntimeInfo.cs:line 69
   at MSBuildProjectTools.LanguageServer.Utilities.MSBuildHelper.DiscoverMSBuildEngine(String baseDirectory, ILogger logger) in D:\Development\github\tintoy\msbuild-project-tools-vscode\lib\server\src\LanguageServer.Common\Utilities\MSBuildHelper.cs:line 96
   at MSBuildProjectTools.LanguageServer.Program.Main() in D:\Development\github\tintoy\msbuild-project-tools-vscode\lib\server\src\LanguageServer\Program.cs:line 39

System.ArgumentException: '' is not a valid version string. (Parameter 'value')
   at NuGet.Versioning.SemanticVersion.Parse(String value)
   at MSBuildProjectTools.LanguageServer.Utilities.DotNetRuntimeInfo.ParseDotNetVersionOutput(TextReader dotnetVersionOutput) in D:\Development\github\tintoy\msbuild-project-tools-vscode\lib\server\src\LanguageServer.Common\Utilities\DotNetRuntimeInfo.cs:line 140
   at MSBuildProjectTools.LanguageServer.Utilities.DotNetRuntimeInfo.GetCurrent(String baseDirectory, ILogger logger) in D:\Development\github\tintoy\msbuild-project-tools-vscode\lib\server\src\LanguageServer.Common\Utilities\DotNetRuntimeInfo.cs:line 69
   at MSBuildProjectTools.LanguageServer.Utilities.MSBuildHelper.DiscoverMSBuildEngine(String baseDirectory, ILogger logger) in D:\Development\github\tintoy\msbuild-project-tools-vscode\lib\server\src\LanguageServer.Common\Utilities\MSBuildHelper.cs:line 96
   at MSBuildProjectTools.LanguageServer.Program.Main() in D:\Development\github\tintoy\msbuild-project-tools-vscode\lib\server\src\LanguageServer\Program.cs:line 39
loligans commented 1 year ago

I think I spoke too soon, sorry. I simply rebuilt the container and it started working again. I appreciate your awesome work by supporting this extension! If you had a sponsor link for the project where I could donate to support, I would definitely like to do that

tintoy commented 1 year ago

What do you get when you run dotnet --version in the container?

tintoy commented 1 year ago

All good, I'm just relieved that it's working for you 🙂

I'll try to improve the error message though.