dotnet / dotnet/project-system

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

Open
#2,811 1 comment 1 reaction 1 assignee Claimed by @davkean View on GitHub
Feature-Error-List Feature-Multi-Targeting Triage-Approved
Dominant language
C#
Stars
1k
Forks
415
PR merge metrics
No merged PRs in 30d

Description

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](https://github.com/dotnet/project-system/files/1291446/MultiTargetBug.zip)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.