dotnet / project-system

The .NET Project System for Visual Studio
MIT License
969 stars 387 forks source link

When conditioning source files between TFMs, build only errors always get reported against first TFM #2811

Open davkean opened 7 years ago

davkean commented 7 years ago

Filed on behalf:

https://developercommunity.visualstudio.com/content/problem/103384/a-multi-target-csproj-project-cant-open-file-with.html. https://developercommunity.visualstudio.com/content/problem/233599/error-output-incorrect-on-multi-trageting-targetfr.html

  1. Open attached project and build

Expected: Two builds errors:

Error   CS1519  Invalid token '}' in class, struct, or interface member declaration MultiTargetBug(net452)  C:\Temp\FooBar\ClassInNet452Only.cs 9   Active
Error   CS0103  The name 'blahThisIsAnError' does not exist in the current context. MultiTargetBug(net452)  C:\Temp\FooBar\ClassInNet452Only.cs 8   Active
Error   CS1519  Invalid token '}' in class, struct, or interface member declaration MultiTargetBug(netcoreapp2.0)   C:\Temp\FooBar\ClassInNet452Only.cs 9   Active

Actual: Three build errors

Error   CS1519  Invalid token '}' in class, struct, or interface member declaration MultiTargetBug(net452)  C:\Temp\FooBar\ClassInNet452Only.cs 9   Active
Error   CS0103  The name 'blahThisIsAnError' does not exist in the current context. MultiTargetBug(net452)  C:\Temp\FooBar\ClassInNet452Only.cs 8   Active
Error   CS1519  Invalid token '}' in class, struct, or interface member declaration MultiTargetBug(netcoreapp2.0)   C:\Temp\FooBar\ClassInNet452Only.cs 9   Active

If you switch to build only you can see that the error coming out of the net452 build is actually being reported against netcoreapp2.0.

MultiTargetBug.zip

davkean commented 4 years ago

Here's a duplicate: https://github.com/dotnet/project-system/issues/3611.