dotnet / dotnet/msbuild

Cross-targeting projects emit difficult to diagnose errors

Open
#4,361 2 comments 1 reaction 0 assignees View on GitHub
Area: Debuggability needs-design triaged
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 8h
Merged PRs (30d)
141

Description

### Steps to reproduce

Create a cross-targeting project that will emit an error on build. See
[xTargetError.zip](https://github.com/microsoft/msbuild/files/3163772/xTargetError.zip)

Build the project with various logger settings.

### Expected behavior
Some log setting that provides enough context to identify which configuration of the project is actually emitting the error

### Actual behavior
No logger setting provides sufficient data. You need to look at a binlog, or more closely inspect a detailed or normal level log to correlate error to other log statements which might include the TargetFramework value.

### Environment data
`msbuild /version` output:
Microsoft (R) Build Engine version 16.1.67-preview+g13843078ee for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

16.1.67.33811

OS info:

If applicable, version of the tool that invokes MSBuild (Visual Studio, dotnet CLI, etc):
dotnet

### Suggested solution

A potential solution for this would be to include global properties in the error spew where the project file is currently emitted.

For example, instead of
```
Class1.cs(6,8): error CS1029: #error: 'this is an error, but from which configuration?' [D:\scratch\xTargetError\xTargetError.csproj]
```
Emit
```
Class1.cs(6,8): error CS1029: #error: 'this is an error, but from which configuration?' [D:\scratch\xTargetError\xTargetError.csproj : TargetFramework=net46]
```

You could make this opt-in with a Console Logger Parameter.

/cc @stephentoub @nguerrera

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.