dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.83k stars 654 forks source link

Extension fails to load a solution with a .vcproj in it #6706

Open rstat1 opened 7 months ago

rstat1 commented 7 months ago

Type: Bug

Issue Description

Extension errors out with an MSBuild crash due to trying to load an old unsupported vcproj file and predictably failing, instead of ignoring it because its a C++ project.

Should be known that the vcproj files in question are part of a project outside of my control, and their existence in the same folder as the C# project is due to an automated process that will overwrite any changes made. Also should be known that Omnisharp handles this scenario just fine.

Steps to Reproduce

Open a .NET SDK C# project that's in a folder containing an old vcproj. Note how none of the intellisense stuff works.

Expected Behavior

The C# extension's LSP server should not be trying to load C++ projects.

Actual Behavior

The C# extension's LSP server tries to C++ projects and crashes.

Logs

C# log

Using dotnet configured on PATH
Dotnet path: /home/rstat1/dotnet/dotnet
Activating C# standalone...
waiting for named pipe information from server...
[stdout] {"pipeName":"/tmp/1f6e96be.sock"}
received named pipe information from server
attempting to connect client to server...
client has connected to server
[Info  - 3:22:56 PM] [Program] Language server initialized
[Info  - 3:22:56 PM] [LanguageServerProjectSystem] Loading /home/rstat1/code/volt2/out/update_engine-bin/jobcache/36be5d2c-673c-47a2-9e13-588339114bc2/Tests/MFC/mfc1/mfc1.sln...
[Error - 3:22:57 PM] [LanguageServerHost] Microsoft.CodeAnalysis.MSBuild.Rpc.RemoteInvocationException: An exception of type Microsoft.Build.Exceptions.InvalidProjectFileException was thrown: The project file "mfc1.vcproj" is in the ".vcproj" file format, which MSBuild no longer supports. Please convert the project by opening it in the Visual Studio IDE or running the conversion tool, or use MSBuild 3.5 or earlier to build it.  /home/rstat1/code/volt2/out/update_engine-bin/jobcache/36be5d2c-673c-47a2-9e13-588339114bc2/Tests/MFC/mfc1/mfc1.sln
   at Microsoft.CodeAnalysis.MSBuild.Rpc.RpcClient.InvokeCoreAsync(Int32 targetObject, String methodName, List`1 parameters, Type expectedReturnType, CancellationToken cancellationToken) in /_/src/Workspaces/Core/MSBuild/Rpc/RpcClient.cs:line 148
   at Microsoft.CodeAnalysis.MSBuild.Rpc.RpcClient.InvokeAsync[T](Int32 targetObject, String methodName, List`1 parameters, CancellationToken cancellationToken) in /_/src/Workspaces/Core/MSBuild/Rpc/RpcClient.cs:line 114
   at Microsoft.CodeAnalysis.LanguageServer.HostWorkspace.LanguageServerProjectSystem.OpenSolutionAsync(String solutionFilePath) in /_/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/LanguageServerProjectSystem.cs:line 109
   at Microsoft.CodeAnalysis.LanguageServer.HostWorkspace.LanguageServerProjectSystem.OpenSolutionAsync(String solutionFilePath) in /_/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/LanguageServerProjectSystem.cs:line 116
   at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`3.StartRequestAsync(TRequestContext context, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/QueueItem.cs:line 136

C# LSP Trace Logs

lsp-trace.txt

Environment information

VSCode version: 1.84.2 C# Extension: 2.12.19 Using OmniSharp: false

Dotnet Information .NET SDK: Version: 8.0.100 Commit: 57efcf1350 Workload version: 8.0.100-manifests.6c33ef20 Runtime Environment: OS Name: fedora OS Version: 39 OS Platform: Linux RID: linux-x64 Base Path: /home/rstat1/dotnet/sdk/8.0.100/ .NET workloads installed: Workload version: 8.0.100-manifests.6c33ef20 There are no installed workloads to display. Host: Version: 8.0.0 Architecture: x64 Commit: 5535e31a71 .NET SDKs installed: 8.0.100-rc.2.23502.2 [/home/rstat1/dotnet/sdk] 8.0.100 [/home/rstat1/dotnet/sdk] .NET runtimes installed: Microsoft.AspNetCore.App 8.0.0-rc.2.23480.2 [/home/rstat1/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 8.0.0 [/home/rstat1/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 8.0.0-rc.2.23479.6 [/home/rstat1/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 8.0.0 [/home/rstat1/dotnet/shared/Microsoft.NETCore.App] Other architectures found: None Environment variables: DOTNET_ROOT [/home/rstat1/dotnet] global.json file: Not found Learn more: https://aka.ms/dotnet/info Download .NET: https://aka.ms/dotnet/download
Visual Studio Code Extensions |Extension|Author|Version|Folder Name| |---|---|---|---| |ayu|teabyii|1.0.5|teabyii.ayu-1.0.5| |coder-remote|coder|0.1.28|coder.coder-remote-0.1.28| |codespaces|GitHub|1.16.2|github.codespaces-1.16.2| |cpptools|ms-vscode|1.19.1|ms-vscode.cpptools-1.19.1-linux-x64| |csharp|ms-dotnettools|2.12.19|ms-dotnettools.csharp-2.12.19-linux-x64| |ecdc|mitchdenny|1.8.0|mitchdenny.ecdc-1.8.0| |EditorConfig|EditorConfig|0.16.4|editorconfig.editorconfig-0.16.4| |firefly|ankitcode|4.0.0|ankitcode.firefly-4.0.0| |format-json|ClemensPeters|1.0.3|clemenspeters.format-json-1.0.3| |go|golang|0.40.0|golang.go-0.40.0| |json-to-go|maracko|0.3.1|maracko.json-to-go-0.3.1| |kotlin|fwcd|0.2.32|fwcd.kotlin-0.2.32| |mongodb-vscode|mongodb|1.3.1|mongodb.mongodb-vscode-1.3.1| |ng-template|Angular|17.0.2|angular.ng-template-17.0.2| |ninja|surajbarkale|0.0.1|surajbarkale.ninja-0.0.1| |nix-develop|jamesottaway|0.0.1|jamesottaway.nix-develop-0.0.1| |ols|DanielGavin|0.1.22|danielgavin.ols-0.1.22| |one-dark-darker|JoelCrosby|1.0.4|joelcrosby.one-dark-darker-1.0.4| |prettify-json|mohsen1|0.0.3|mohsen1.prettify-json-0.0.3| |remote-containers|ms-vscode-remote|0.321.0|ms-vscode-remote.remote-containers-0.321.0| |remote-explorer|ms-vscode|0.4.1|ms-vscode.remote-explorer-0.4.1| |remote-ssh|ms-vscode-remote|0.107.1|ms-vscode-remote.remote-ssh-0.107.1| |remote-ssh-edit|ms-vscode-remote|0.86.0|ms-vscode-remote.remote-ssh-edit-0.86.0| |render-crlf|medo64|1.7.1|medo64.render-crlf-1.7.1| |rest-client|humao|0.25.1|humao.rest-client-0.25.1| |rust-analyzer|rust-lang|0.3.1748|rust-lang.rust-analyzer-0.3.1748-linux-x64| |shader|slevesque|1.1.5|slevesque.shader-1.1.5| |theme-monokai-pro-vscode|monokai|1.2.1|monokai.theme-monokai-pro-vscode-1.2.1| |url-encode|flesler|1.1.0|flesler.url-encode-1.1.0| |vsc-material-theme|Equinusocio|34.3.0|equinusocio.vsc-material-theme-34.3.0| |vsc-material-theme-icons|equinusocio|3.2.0|equinusocio.vsc-material-theme-icons-3.2.0| |vscode-antlr4|mike-lischke|2.4.3|mike-lischke.vscode-antlr4-2.4.3| |vscode-clangd|llvm-vs-code-extensions|0.1.25|llvm-vs-code-extensions.vscode-clangd-0.1.25| |vscode-css-formatter|aeschli|1.0.2|aeschli.vscode-css-formatter-1.0.2| |vscode-dotnet-runtime|ms-dotnettools|2.0.0|ms-dotnettools.vscode-dotnet-runtime-2.0.0| |vscode-gn|npclaudiu|1.1.0|npclaudiu.vscode-gn-1.1.0| |vscode-icons|vscode-icons-team|12.6.0|vscode-icons-team.vscode-icons-12.6.0| |vscode-proto|sankethdev|0.0.6|sankethdev.vscode-proto-0.0.6|;

Extension version: 2.12.19 VS Code version: Code 1.84.2 (1a5daa3a0231a0fbba4f14db7ec463cf99d7768e, 2023-11-09T10:50:47.800Z) OS version: Linux x64 6.5.12-300.fc39.x86_64 Modes:

System Info |Item|Value| |---|---| |CPUs|11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz (8 x 4100)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
video_decode: enabled
video_encode: disabled_software
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off| |Load (avg)|1, 0, 0| |Memory (System)|31.12GB (24.18GB free)| |Process Argv|--unity-launch| |Screen Reader|no| |VM|0%| |DESKTOP_SESSION|gnome| |XDG_CURRENT_DESKTOP|GNOME| |XDG_SESSION_DESKTOP|gnome| |XDG_SESSION_TYPE|wayland|
jasonmalinowski commented 6 months ago

So the exception seems to be coming from MSBuild here:

https://github.com/dotnet/msbuild/blob/f97064d3b83485628dec0769659e786b55f6835a/src/Build/Construction/Solution/SolutionFile.cs#L1297

It doesn't appear there's any public way to bypass that; there's an internal field but that's not settable via a Public API.