dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.85k stars 667 forks source link

Show both .sln and .csproj files in project selector #903

Closed wjk closed 14 hours ago

wjk commented 7 years ago

Environment data

.NET Command Line Tools (1.0.0-preview4-004071)

Product Information:
 Version:            1.0.0-preview4-004071
 Commit SHA-1 hash:  9855dc0088

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.14393
 OS Platform: Windows
 RID:         win10-x64

VS Code version: 1.7.1 C# Extension version: v1.5-beta7

Steps to reproduce

In my private repo, I have a number of MSBuild-based .NET Core projects I intend on using VSCode with. However, my build process also involves creating (using CMake) and building a completely unrelated Visual C++-based solution. omnisharp-vscode then locks on to the *.sln file generated by CMake, which contains no C# projects, and prevents me from accessing the loose *.csproj files that constitute the bulk of my project.

Expected behavior

omnisharp-vscode should give an option to access loose csproj files, even when a solution file is detected.

Actual behavior

I can't do this.

DustinCampbell commented 7 years ago

Great bug -- thanks!

crysyn commented 6 years ago

Is there any progress on this or work around (like telling OmniSharp which SLN to look at?) or the like? Arguably one of the strongest points of fast C# development and iteration revolves around Intellisense working.. Since OmniSharp is loading our test environment sln instead of or dev sln, it does not function at all.

DustinCampbell commented 6 years ago

You can tell OmniSharp what to launch on by clicking the little OmniSharp icon at the bottom right of the VS Code status bar. (This is visible when a C# file is in the active editor.) You can use this to pick different solutions.

crysyn commented 6 years ago

Ah, that is a bit less painful. Thanks.

0xabu commented 6 years ago

I have the same issue -- I have a .csproj file I want to use, but it's being ignored in favour of other .sln files in the workspace tree. I've noticed that the file picker @DustinCampbell mentioned is a bit peculiar. If any .sln files exist in the workspace tree, only .sln files appear in the file picker and I can't use my csproj. If I start a new instance of vscode and just open the relevant sub-folder (which has only the .csproj in it), then vscode/omnisharp is happy to use my .csproj file.

(Yes, I could create another dummy .sln file that refers only to the .csproj I want to use, but it's not clear why I should need to.)

0xabu commented 6 years ago

Update: after looking at resourcesToLaunchTargets, I realised that I'm not in fact opening the csproj file I wanted, but just its containing folder (which has the same name, and is also functional).

So please ignore my comment above -- this bug is really just about the following TODO:

// TODO:
//   * It should be possible to choose a .csproj as a launch target
prensing commented 6 years ago

I think I am having the same problem, so want to re-enforce working on this. I have a project tree which contains a (Windows) VisualStudio solution file plus projects. I am now trying to compile it on Linux with .NET Core and VS Code. OmniSharp insists on loading the .sln file, which fails, and it does not offer any pickers.

If I rename the .sln and .csproj associated with VisualStudio, then OmniSharp correctly loads the Core csproj file and appears to work properly.

bruce31 commented 3 years ago

Why is there no progress on this? I avoid .sln files wherever possible in favour of loose .csproj folders. If I need a .sln file because of a heavy VStudio debugging need, I lose the ability to open the root folder of a collection of related projects that have a single set of documentation. Very frustrating. tried excluding */.sln in omnisharp.json file located in %USERPROFILE%/.omnisharp/ the sln file still loaded littering .slnXX files all over the place seems like the only workaround

JoeRobich commented 14 hours ago

Closing as a lot has changed with the project selector since this issue was opened. For OmniSharp we now show project .sln, .slnf, and .csproj files in the selector.

image