dotnet / dotnet/msbuild

ConfigurationManager binding redirect targets an assembly missing from Microsoft.Build.vsix

Open
#14,404 5 comments 0 reactions 1 assignee Claimed by @ViktorHofer View on GitHub
triaged
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 6h
Merged PRs (30d)
139

Description

### Issue Description

Visual Studio 2022 17.14.36 ships MSBuild 17.14.51 with a binding redirect for `System.Configuration.ConfigurationManager` to version `10.0.0.8`.

However, `Microsoft.Build.vsix` does not contain that assembly, and the Visual Studio catalog does not include another package that supplies it. Consequently, in-process MSBuild tasks that transitively depend on ConfigurationManager can no longer load their task-local assembly.

This is a regression from MSBuild 17.14.40.

### Steps to Reproduce

1. Download and extract the attached `MSBuild-17.14.51-ConfigurationManager-Repro.zip`.
2. Open a Visual Studio Developer PowerShell.
3. Confirm MSBuild 17.14.51 is active:

```powershell
msbuild -version
```

The output must start with `17.14.51`.

4. From the extracted directory, run:

```powershell
.\repro.ps1
```

The script builds a net472 MSBuild task that calls a netstandard2.0 dependency referencing `System.Configuration.ConfigurationManager` 7.0.0, then invokes the task in-process.

[MSBuild-17.14.51-ConfigurationManager-Repro.zip](https://github.com/user-attachments/files/30103907/MSBuild-17.14.51-ConfigurationManager-Repro.zip)

### Expected Behavior

The task should execute successfully:

```text
App settings: 0
```

This is the behavior under MSBuild 17.14.40.

### Actual Behavior

MSBuild 17.14.51 fails:

```text
error MSB4018: The "ReadConfigTask" task failed unexpectedly.
error MSB4018: System.IO.FileNotFoundException:
Could not load file or assembly
'System.Configuration.ConfigurationManager, Version=7.0.0.0,
Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
or one of its dependencies.
```

### Analysis

Related change: #14127.

That change added the following binding policy to the amd64 MSBuild configuration:

```xml



```

For amd64 MSBuild, the `codeBase` resolves to:

```text
MSBuild\Current\Bin\System.Configuration.ConfigurationManager.dll
```

That file is absent from `Microsoft.Build.vsix` 17.14.51. The Visual Studio 17.14.36 catalog also contains no separate package that supplies it.

`AppDomain.CurrentDomain.ApplyPolicy` confirms that the host redirect is applied:

```text
MSBuild 17.14.40:
7.0.0.0 -> 7.0.0.0

MSBuild 17.14.51:
7.0.0.0 -> 10.0.0.8
```

The resulting `FileNotFoundException` reports the original requested identity, `7.0.0.0`, even though the host policy redirected the bind to `10.0.0.8`.

The servicing target includes ConfigurationManager in `_DeployedRuntimeAssembly`, but only adds a servicing assembly to `ReferenceCopyLocalPaths` when the package ID was already present in MSBuild's original `ReferenceCopyLocalPaths`:

```xml

```

MSBuild itself does not reference ConfigurationManager, so its package ID is not present in `_RuntimeCopyLocalIds`. The assembly is omitted even though the host configuration redirects external tasks to it.

All servicing-wave binding redirects were compared against both x86 and amd64 VSIX payload locations. ConfigurationManager is the only redirect whose target is missing.

Copying the net462 ConfigurationManager 10.0.8 assembly to the declared location makes the attached reproduction succeed under MSBuild 17.14.51.

Suggested fixes:

1. Unconditionally include ConfigurationManager 10.0.8 at:

```text
Contents\MSBuild\Current\Bin\System.Configuration.ConfigurationManager.dll
```

2. Alternatively, remove the ConfigurationManager binding redirect and `codeBase`.

3. Add a packaging test verifying that every MSBuild `codeBase` target exists in the generated VSIX.

4. Add a regression test using an in-process custom task with a task-local ConfigurationManager dependency.

### Versions & Configurations

Working:

```text
Visual Studio 2022 17.14.35
MSBuild 17.14.40.60911
```

Failing:

```text
Visual Studio 2022 17.14.36
MSBuild 17.14.51.32402
```

Operating system: Windows
Architecture: x64
MSBuild runtime: .NET Framework

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.