dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.84k stars 666 forks source link

.sln files in sub folders take precedence over root .csproj file #6459

Open YorVeX opened 11 months ago

YorVeX commented 11 months ago

Type: Bug

Issue Description

I have a .csproj file in the root folder, which is the relevant one I want to use. This main project also doesn't have an .sln file. image

For reference, I also keep source files of used (and slightly modified) 3rd party libraries including its VS .sln files in sub folders, but they are not relevant for me when I open the root folder for my main solution.

image

When I start VS Code with this project, the C# extension asks to select a solution file, and fully ignores the .csproj file in the root folder that would actually be relevant. Previously with older versions of the C# extension and/or OmniSharp being used this hasn't been a problem, but now it is.

image image

Due to this I cannot really use the IDE with this project: image

Steps to Reproduce

Create a folder structure with a .csproj file in the root folder and unrelated .sln files in a sub directory.

Expected Behavior

The extension already detects that there are multiple project files in the folder structure, the list of project files to select should include .csproj and .sln files.

Actual Behavior

Only .sln files are offered for selection.

Logs

C# log

Using dotnet configured on PATH Dotnet path: C:\Program Files\dotnet\dotnet.exe Activating C# standalone... waiting for named pipe information from server... [stdout] {"pipeName":"\\\\.\\pipe\\aeabb6d8-3ada-4d40-ad7a-1b233d3ab3ff"} received named pipe information from server attempting to connect client to server... client has connected to server [Info - 4:01:44 PM] [Program] Language server initialized Using dotnet configured on PATH

Environment information

VSCode version: 1.82.2 C# Extension: 2.4.4 Using OmniSharp: false

Dotnet Information .NET SDK: Version: 7.0.401 Commit: eb26aacfec Runtime Environment: OS Name: Windows OS Version: 10.0.22631 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\7.0.401\ Host: Version: 7.0.11 Architecture: x64 Commit: ecb34f85ec .NET SDKs installed: 5.0.416 [C:\Program Files\dotnet\sdk] 6.0.414 [C:\Program Files\dotnet\sdk] 7.0.401 [C:\Program Files\dotnet\sdk] .NET runtimes installed: Microsoft.AspNetCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.22 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 7.0.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.22 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 7.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.22 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 7.0.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Other architectures found: x86 [C:\Program Files (x86)\dotnet] Environment variables: Not set 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| |---|---|---|---| |add-reference|adrianwilczynski|1.0.2|adrianwilczynski.add-reference-1.0.2| |azure-repos|ms-vscode|0.36.0|ms-vscode.azure-repos-0.36.0| |batch-runner|NilsSoderman|1.1.2|nilssoderman.batch-runner-1.1.2| |Bookmarks|alefragnani|13.4.1|alefragnani.bookmarks-13.4.1| |cmake|twxs|0.0.17|twxs.cmake-0.0.17| |cmake-tools|ms-vscode|1.15.31|ms-vscode.cmake-tools-1.15.31| |copilot|GitHub|1.121.456|github.copilot-1.121.456| |copilot-chat|GitHub|0.7.1|github.copilot-chat-0.7.1| |copilot-labs|GitHub|0.15.1019|github.copilot-labs-0.15.1019| |cpptools|ms-vscode|1.17.5|ms-vscode.cpptools-1.17.5-win32-x64| |cpptools-extension-pack|ms-vscode|1.3.0|ms-vscode.cpptools-extension-pack-1.3.0| |cpptools-themes|ms-vscode|2.0.0|ms-vscode.cpptools-themes-2.0.0| |csharp|ms-dotnettools|2.4.4|ms-dotnettools.csharp-2.4.4-win32-x64| |csharpextensions|kreativ-software|1.7.3|kreativ-software.csharpextensions-1.7.3| |discord-vscode|icrawl|5.8.0|icrawl.discord-vscode-5.8.0| |docomment|k--kato|1.0.0|k--kato.docomment-1.0.0| |EditorConfig|EditorConfig|0.16.4|editorconfig.editorconfig-0.16.4| |github-markdown-preview|bierner|0.3.0|bierner.github-markdown-preview-0.3.0| |gitlens|eamodio|14.3.0|eamodio.gitlens-14.3.0| |jupyter|ms-toolsai|2023.8.1002501831|ms-toolsai.jupyter-2023.8.1002501831-win32-x64| |jupyter-keymap|ms-toolsai|1.1.2|ms-toolsai.jupyter-keymap-1.1.2| |jupyter-renderers|ms-toolsai|1.0.17|ms-toolsai.jupyter-renderers-1.0.17| |luahelper|yinfei|0.2.24|yinfei.luahelper-0.2.24| |makefile-tools|ms-vscode|0.7.0|ms-vscode.makefile-tools-0.7.0| |markdown-checkbox|bierner|0.4.0|bierner.markdown-checkbox-0.4.0| |markdown-emoji|bierner|0.3.0|bierner.markdown-emoji-0.3.0| |markdown-footnotes|bierner|0.1.1|bierner.markdown-footnotes-0.1.1| |markdown-mermaid|bierner|1.20.0|bierner.markdown-mermaid-1.20.0| |markdown-preview-github-styles|bierner|2.0.3|bierner.markdown-preview-github-styles-2.0.3| |markdown-yaml-preamble|bierner|0.1.0|bierner.markdown-yaml-preamble-0.1.0| |nsis|idleberg|4.2.4|idleberg.nsis-4.2.4| |nugetpackagemanagergui|aliasadidev|2.0.6|aliasadidev.nugetpackagemanagergui-2.0.6| |powershell|ms-vscode|2023.6.0|ms-vscode.powershell-2023.6.0| |python|ms-python|2023.16.0|ms-python.python-2023.16.0| |remote-repositories|ms-vscode|0.38.1|ms-vscode.remote-repositories-0.38.1| |remote-wsl|ms-vscode-remote|0.81.7|ms-vscode-remote.remote-wsl-0.81.7| |remotehub|GitHub|0.60.0|github.remotehub-0.60.0| |rss|luyuhuang|0.10.4|luyuhuang.rss-0.10.4| |todo-tree|Gruntfuggly|0.0.226|gruntfuggly.todo-tree-0.0.226| |vscode-autohotkey-plus-plus|mark-wiemer|5.0.3|mark-wiemer.vscode-autohotkey-plus-plus-5.0.3| |vscode-counter|uctakeoff|3.2.1|uctakeoff.vscode-counter-3.2.1| |vscode-dotnet-runtime|ms-dotnettools|1.8.0|ms-dotnettools.vscode-dotnet-runtime-1.8.0| |vscode-guid|heaths|1.7.0|heaths.vscode-guid-1.7.0| |vscode-gutter-preview|kisstkondoros|0.30.0|kisstkondoros.vscode-gutter-preview-0.30.0| |vscode-jupyter-cell-tags|ms-toolsai|0.1.8|ms-toolsai.vscode-jupyter-cell-tags-0.1.8| |vscode-jupyter-slideshow|ms-toolsai|0.1.5|ms-toolsai.vscode-jupyter-slideshow-0.1.5| |vscode-pylance|ms-python|2023.9.30|ms-python.vscode-pylance-2023.9.30| |xml|DotJoshJohnson|2.5.1|dotjoshjohnson.xml-2.5.1|;

Extension version: 2.4.4 VS Code version: Code 1.82.2 (abd2f3db4bdb28f9e95536dfa84d8479f1eb312d, 2023-09-14T05:55:25.390Z) OS version: Windows_NT x64 10.0.22631 Modes:

System Info |Item|Value| |---|---| |CPUs|AMD Ryzen 5 7640U w/ Radeon 760M Graphics (12 x 3493)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: enabled_on
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: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled| |Load (avg)|undefined| |Memory (System)|12.73GB (3.99GB free)| |Process Argv|--crash-reporter-id 6fb09b72-737b-406a-9aff-30d009da46b7| |Screen Reader|no| |VM|0%|
A/B Experiments ``` vsliv368:30146709 vsreu685:30147344 python383cf:30185419 vspor879:30202332 vspor708:30202333 vspor363:30204092 vslsvsres303:30308271 vserr242:30382549 pythontb:30283811 vsjup518:30340749 pythonptprofiler:30281270 vshan820:30294714 vstes263:30335439 vscod805cf:30301675 binariesv615:30325510 bridge0708:30335490 bridge0723:30353136 vsaa593cf:30376535 pythonvs932:30410667 py29gd2263cf:30792227 vscaat:30438848 vsclangdf:30486550 c4g48928:30535728 dsvsc012:30540252 pynewext54:30695312 azure-dev_surveyone:30548225 282f8724:30602487 89544117:30613380 showlangstatbar:30737416 03d35959:30757346 pythonfmttext:30731395 fixshowwlkth:30771522 showindicator:30805244 pythongtdpath:30769146 i26e3531:30792625 pythonnosmt12:30797651 pythonidxpt:30805730 pythonnoceb:30805159 copilotsettingt:30839829 asynctok:30821568 dsvsc013:30795093 dsvsc014:30804076 diffeditorv2:30821572 dsvsc015:30845448 ```
BinToss commented 8 months ago

The old Omnisharp engine is Project-oriented and had no support for solution files. If users wanted support for Solution files, they would have to install separate, third-party extensions like TinToy's Solution Explorer. The current engine is Solution-oriented and cannot directly open project files. Unlike Omnisharp, it leverages Language Server Protocol for many editor features.

You can... A. Create a new solution file for your "primary" project. Because they are familiar to most .NET developers, MSBuild's Solution files were reused for their ability to store MSBuild's build solution information and build matrix (like CMake's CMakelists.txt). B. Set option csharp.useOmnisharp to true to stop using the new features and C# LSP.

BinToss commented 8 months ago

Also, this is probably a duplicate of https://github.com/dotnet/vscode-csharp/issues/5722

JoeRobich commented 8 months ago

The old Omnisharp engine is Project-oriented and had no support for solution files.

@BinToss OmniSharp absolutely supports solution files. You may have configured it to work differently, but the C# 1.x extension, which only used OmniSharp, defaulted to opening solution files over project files.