Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kindly document in a prominent place that a sln-file is needed for much of the functionality to work #7683

Open
emmenlau opened this issue Oct 22, 2024 · 4 comments

Comments

@emmenlau
Copy link

emmenlau commented Oct 22, 2024

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 and dotnet 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 dedicated sln 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 a nutget 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:

  • A sln-file linking all the csproj-files is mandatory?
  • No non-working sln-files in subdirectories should exist?

Applicable Scenarios

Describe alternatives you've considered

Additional context

@JoeRobich
Copy link
Member

JoeRobich commented Oct 23, 2024

@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 (#7652) have helped you?

@emmenlau
Copy link
Author

@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:

  • How to create a new, clean sln-file in the root of the project, so that all C# files are indexed?
  • Is it supported to work without any sln-file?
  • How to avoid loading a random sln-file?

@emmenlau
Copy link
Author

Hmm, today I opened a different project, and there is a popup message:
Image

I have not seen this in the other project before. This is actually indeed helpful, albeit it could still better describe the problem.

@emmenlau emmenlau changed the title Kindly document in a prominent place that a sln-file is needed to much of the functionality to work Kindly document in a prominent place that a sln-file is needed for much of the functionality to work Oct 24, 2024
@dibarbet
Copy link
Member

cc @webreidi - do we have documentation on this for C# Dev Kit?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants