dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.83k stars 659 forks source link

Smarter behavior in sln with multitargetted projects #3288

Open AndrewTriesToCode opened 4 years ago

AndrewTriesToCode commented 4 years ago

Hello,

I develop a library which targets multiple .Net core frameworks/standards. In the same solution I have a samples folder for example projects that target only netcoreapp2.2.

If the library project uses <TargetFrameworks>netcoreapp3.0;netcoreapp2.2</TargetFrameworks> and a sample project uses <TargetFramework>netcoreapp3.0</TargetFramework> everything is good.

However if a sample project only targets netcoreapp2.2 and has a <ProjectReference> to the library VS Code flags all sorts of errors in the sample project. Omnisharp-vscode seems to only see the referenced project as targettiing the first framework listed in its <TargetFrameworks> entry.

This has left me in a position where my project has hundreds of errors in "normal" state while opened in VSCode but where a dotnet build runs perfectly on the command line.

If it helps my project is https://github.com/Finbuckle/Finbuckle.MultiTenant

Clone that and open the sln in VSCode and you will see what I mean.

AndrewTriesToCode commented 4 years ago

Also I'll add that the obj folders some target frameworks are flagged for errors but the first listed target framework's obj folder is correctly ignored.

Edit: I resolved the obj file errors by adding a "folder" project type to my sln file. The folder I added was unrelated to the obj folders but it seemed to fix that issue. The original issue remains.

Thanks!

cartermp commented 4 years ago

Yeah, this is a pretty big project system-level feature. Currently OmniSharp just loads the first target specified. It doesn't have a robust system for handling multiple targets like the Visual Studio project system does.

xqrzd commented 4 years ago

Thanks for the info, I was able to fix my issue by rearranging my target frameworks so the newest framework is first.

candoumbe commented 3 years ago

Hi ! As I'm running into the same kind of using on one of my project ... Is there any news on addressing this issue ? I'm about to move away from Windows as my dev OS and this is very critical to me.

Thanks in advance for your answer and keep up the good work