Skip to content

[rel/18.6] Fix stale binding redirects for SCRU/Memory/Buffers/SCI - #16090

Merged
Amaury Levé (Evangelink) merged 1 commit into
microsoft:rel/18.6from
Evangelink:dev/amauryleve/fix-unsafe-redirect-rel186
Jun 3, 2026
Merged

[rel/18.6] Fix stale binding redirects for SCRU/Memory/Buffers/SCI#16090
Amaury Levé (Evangelink) merged 1 commit into
microsoft:rel/18.6from
Evangelink:dev/amauryleve/fix-unsafe-redirect-rel186

Conversation

@Evangelink

Copy link
Copy Markdown
Member

The hardened binding-redirect verifier (#15778, now wired up on rel/18.6 after #16083) is catching four more stale binding redirects in testhost.x86 and datacollector app.config files. Each one targets a higher version than what actually ships beside the exe in the Microsoft.TestPlatform.CLI nupkg TestHostNetFramework folder:

Assembly Redirect newVersion Shipped DLL
System.Runtime.CompilerServices.Unsafe 6.0.3.0 6.0.0.0
System.Memory 4.0.5.0 4.0.1.2
System.Buffers 4.0.5.0 4.0.3.0
System.Collections.Immutable 10.0.0.0 9.0.0.0

These four were bumped by the auto-fix in #15724 when the layout contained the newer AVs, but the rel/18.6 package layout has since reverted to the older transitive versions. A redirect pointing at a version that is not shipped causes FileLoadException in hosts without their own binding redirects (e.g. Azure DevOps Distributed Test Agent — same anti-pattern as #15776 and #16083).

This PR mirrors what build.cmd -c Release would produce locally via eng/verify-binding-redirects.ps1 auto-fix: narrows both newVersion and the upper bound of oldVersion to the actual shipped DLL version, for both src/testhost.x86/app.config and src/datacollector/app.config.

src/vstest.console/app.config is intentionally left untouched — vstest.console.exe ships only in Microsoft.TestPlatform (NonShipping) packages, which are not in the verifier's checked set, so it can't be auto-fixed without risk to a layout we don't validate.

Failing build: https://dev.azure.com/dnceng-public/public/_build/results?buildId=1448463

The hardened binding-redirect verifier (microsoft#15778) is now catching four stale
binding redirects in testhost.x86 and datacollector app.configs. The
redirects point at versions that are higher than what actually ships
beside the exe in the Microsoft.TestPlatform.CLI nupkg
(TestHostNetFramework folder):

| Assembly                                | Redirect | Shipped |
|-----------------------------------------|----------|---------|
| System.Runtime.CompilerServices.Unsafe  | 6.0.3.0  | 6.0.0.0 |
| System.Memory                           | 4.0.5.0  | 4.0.1.2 |
| System.Buffers                          | 4.0.5.0  | 4.0.3.0 |
| System.Collections.Immutable            | 10.0.0.0 | 9.0.0.0 |

These redirects were bumped by the auto-fix script in microsoft#15724 when those
higher AV variants were present in the layout at the time, but the rel/18.6
package layout has since reverted to the older transitive versions.
A redirect targeting a version that is not actually shipped causes
FileLoadException at runtime in hosts without their own binding
redirects (e.g. Azure DevOps Distributed Test Agent).

Mirrors the auto-fix output of build.cmd -c Release: newVersion and the
upper bound of oldVersion are narrowed to the actual shipped DLL version.

vstest.console/app.config is intentionally left untouched - vstest.console.exe
ships in Microsoft.TestPlatform.NonShipping packages that are not in the
verifier's checked set and whose DLL versions are not verified here.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Evangelink
Amaury Levé (Evangelink) merged commit 9ebba9a into microsoft:rel/18.6 Jun 3, 2026
2 of 5 checks passed
@Evangelink
Amaury Levé (Evangelink) deleted the dev/amauryleve/fix-unsafe-redirect-rel186 branch June 3, 2026 21:10
Amaury Levé (Evangelink) added a commit that referenced this pull request Jun 3, 2026
…d mode (#16091)

* Revert "[rel/18.6] Fix stale binding redirects for SCRU/Memory/Buffers/SCI (#16090)"

This reverts commit 9ebba9a.

* [rel/18.6] Skip nupkg verifier in .NET product build mode

The binding redirect verifier in verify-nupkgs.ps1 fails in the dotnet/dotnet
VMR build because source-built dependency packages have older AssemblyVersion
stamps than NuGet.org packages (e.g. System.Runtime.CompilerServices.Unsafe
ships as 6.0.0.0 from source-build but 6.0.3.0 from NuGet.org).

The newVersion of a bindingRedirect must equal the AssemblyVersion of the
DLL actually shipped beside the exe, so no single value can satisfy both
the VMR/source-build pipeline (dnceng-public) and the internal pipeline
(dnceng / NuGet.org-based) at the same time.

Back-port the same skip already present on rel/18.8 and main: gate the
_VerifyNuGetPackages target on DotNetBuild != 'true' so the VMR no longer
runs the verifier, while the internal pipeline (which produces the actually-
shipped packages) continues to validate the redirects.

This also accompanies the revert of #16090, which had downgraded the
testhost.x86/datacollector redirects to the VMR-side values and thereby
broke the internal pipeline's verifier check (the shipped DLLs there are
the NuGet.org 6.0.3.0/4.0.5.0/4.0.5.0/10.0.0.0 variants).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

1 participant