Open emmenlau opened 1 week ago
@emmenlau Are you also using the C# DevKit? C# extension on its own shouldn't require a solution file as it will load all the .csproj files in the repo. When the DevKit is installed it takes over project loading responsibilities and its behavior differs from the C# extension.
We are also trying to make it more apparent when you are working on files outside the open workspace (solution or project files). Would a notification such as the one added in this PR (https://github.com/dotnet/vscode-csharp/pull/7652) have helped you?
@emmenlau Are you also using the C# DevKit?
Yes, actually I'm also using the C# DevKit. Maybe that added to the confusion. With this insight, I think my feature request applies more to C# DevKit than to the C# extension.
We are also trying to make it more apparent when you are working on files outside the open workspace (solution or project files). Would a notification such as the one added in this PR (#7652) have helped you?
This notification would have helped, yes. However, it would only have cut my debugging time from something like 5 hours to maybe 2 or 3 hours. My challenge was, that I would never have assumed for the extension to load a random sln file in a subdirectory. Even more so, because this sln-file is only used by the CI system, and does not even correctly load outside the CI.
In my humble opinion, the auto-loading of sln-files should be a lot more transparent. Something like the following notification message would have greatly helped:
Warning: You have opened a VSCode project, but the C# DevKit extension will only consider C# sources that are referenced from a Solution File (*.sln). There is no Solution File in the root of your project, but multiple solutions files have been detected in sub-folders of your project. Randomly, the first Solution File has been loaded. If this is not what you want, consider the documentation at ...some link to an explanation on how to work with this...
In the linked documentation, I guess multiple questions could/should be addressed:
Hmm, today I opened a different project, and there is a popup message:
I have not seen this in the other project before. This is actually indeed helpful, albeit it could still better describe the problem.
cc @webreidi - do we have documentation on this for C# Dev Kit?
Is your feature request related to a problem? Please describe.
For several hours, I could not get intellisense working in the C# extension, and there was no helpful setting or error message to the rescue. By pure chance, and after hours of googling, I found that a sln-file may help. After using
dotnet new sln
anddotnet sln add ...path/to/all/relevant/csproj
, intellisense started working!!!My setup is so that I have a project that uses mostly
csproj
files, but also two or three dedicatedsln
files buried in subdirectories. One of these sln-files is exclusively used in CI tests. It points to a sub-project, that is not meant to be built or used in VSCode. This sub-project only works correctly (i.e. can only do anutget restore
) when used inside of our CI system.I think this additional sln-file may be related to the problem I was having. This is because I'm under the impression that the C# extension tried to load one or more of the sln-files in subdirectories and then failed to correctly index my project(?)
Describe the solution you would like
It would be great if this could be better documented on the front page of the C# extension. Possibly, there could also be better error or logging messages?. I'm not sure which of the following two applies:
Applicable Scenarios
Describe alternatives you've considered
Additional context