I have folders structured like this: project/csproj A, project/csproj B If I open in vs code project dir, omnisharp works for csproj B only. If I open in vs code project/csproj A directory, omnisharp works for this project.
How fix that so I can open project directory and have working omnisharp for both projects?
Broken project is nunit type if that matters. I tried reloading vscode, disabling/enabling omnisharp. I created project in empty directory with
dotnet new nunit -n=projectB
A solution is specified by a sln file, if you don't have one yet, just create a new one in the solution-level folder
dotnet new sln
And then, you must add the project references to the solution
dotnet sln path/to/solution add path/to/project
And if the omnisharp does not update it, restart it or vs code.
Omnisharp can only support a single project or solution, therefore, to support multiple projects, you must use "solution", which is not just a folder but with a sln file.
Your folder structure is antipattern and not naturally supported, because .NET Core uses SDK-style csproj project, which adds all source files in the project-level folder (which is where the csproj file is), so having multiple csproj files inside one project-level folder is just for one project with multiple targetings. If your project A and B is in the same folder, it means they may contain duplicate source files that may cause errors on conflict of types, unless you specified source exclusion respectively in the csproj files.
The recommanded folder structure is
<Solution and git repository level folder>
|-- src
| |-- <Project level folders>
| | |-- <Folder structures based on namespace>
| | | └-- <Source files>
| | |-- <Asset files with approprate folder structure>
| | └-- <The csproj file>
| |-- Directory.Build.props (Common MSBuild props for all src projects)
| └-- Directory.Build.targets (Common MSBuild targets for all src projects)
|-- test
|-- └-- <Test projects with similar folder structure to src>
|-- build
|-- └-- <Common MSBuild props and targets files to be referenced by src and test>
|-- docs
| └-- <Documents>
|-- <Other repository assets>
└-- <The sln file>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With