Skip to content

Report line number in app.config error#12535

Merged
rainersigwald merged 2 commits intodotnet:mainfrom
rainersigwald:better-binding-redirect-errors
Sep 30, 2025
Merged

Report line number in app.config error#12535
rainersigwald merged 2 commits intodotnet:mainfrom
rainersigwald:better-binding-redirect-errors

Conversation

@rainersigwald
Copy link
Member

Example outputs with two intentionally misaligned versions:

S:\msbuild\src\MSBuild\app.config(36): error : Binding redirect for 'Microsoft.Bcl.AsyncInterfaces' redirects to a different version (9.0.0.123) than MSBuild ships (9.0.0.9). [S:\msbuild\src\MSBuild\MSBuild.csproj::TargetFramework=net472]
S:\msbuild\src\MSBuild\app.amd64.config(203): error : Binding redirect for 'System.Reflection.Metadata' redirects to a different version (9.0.0.18) than MSBuild ships (9.0.0.9). [S:\msbuild\src\MSBuild\MSBuild.csproj::TargetFramework=net472]

This came up when working on a runtime-library version bump; the errors nicely broke the build but the fix could have been easier.

Example outputs with two intentionally misaligned versions:

```
S:\msbuild\src\MSBuild\app.config(36): error : Binding redirect for 'Microsoft.Bcl.AsyncInterfaces' redirects to a different version (9.0.0.123) than MSBuild ships (9.0.0.9). [S:\msbuild\src\MSBuild\MSBuild.csproj::TargetFramework=net472]
S:\msbuild\src\MSBuild\app.amd64.config(203): error : Binding redirect for 'System.Reflection.Metadata' redirects to a different version (9.0.0.18) than MSBuild ships (9.0.0.9). [S:\msbuild\src\MSBuild\MSBuild.csproj::TargetFramework=net472]
```
@rainersigwald rainersigwald self-assigned this Sep 15, 2025
Copilot AI review requested due to automatic review settings September 15, 2025 22:11
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances error reporting by adding line number information to binding redirect validation errors in the MSBuild package dependency version checker. Previously, errors only included the assembly name and version mismatch details, making it difficult to locate the problematic configuration in app.config files.

Key changes:

  • Enhanced error messages to include file path and line number for easier troubleshooting
  • Replaced XmlDocument parsing with XmlReader to capture line information
  • Changed AppConfig parameter from string to ITaskItem for better metadata access

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants