Skip to content

[fix] Harden binding redirect validation to catch missing DLLs#15778

Merged
nohwnd merged 5 commits into
microsoft:mainfrom
nohwnd:fix-redirect-validation
May 14, 2026
Merged

[fix] Harden binding redirect validation to catch missing DLLs#15778
nohwnd merged 5 commits into
microsoft:mainfrom
nohwnd:fix-redirect-validation

Conversation

@nohwnd
Copy link
Copy Markdown
Member

@nohwnd nohwnd commented May 14, 2026

verify-binding-redirects.ps1 silently skipped redirects whose DLL wasn't in the package layout. This allowed #15765 — the DiagnosticSource redirect shipped in testhost.exe.config but the DLL was excluded from the .nuspec.

Now it's an error: if the package exists but a redirect's target DLL is missing, the script fails. The whole-package-missing case (e.g. VMR where the exe isn't found at all) is still a skip.

Copilot AI review requested due to automatic review settings May 14, 2026 11:01
Copy link
Copy Markdown
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 tightens packaging validation for binding redirects so redirects to assemblies missing from the package layout are treated as validation errors instead of being silently skipped.

Changes:

  • Detects binding redirects whose target DLL cannot be found in the extracted package layout.
  • Records those cases as validation errors and emits explicit error output.

Comment thread eng/verify-binding-redirects.ps1
Comment thread eng/verify-binding-redirects.ps1 Outdated
Change verify-binding-redirects.ps1 to fail when a binding redirect
references a DLL that isn't in the package layout. Previously this was
silently skipped, which allowed microsoft#15765 — a redirect for
DiagnosticSource 8.0.0.1 shipped in the config but the DLL was
excluded from the package.

The whole-package-missing case (VMR) is still a skip.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@nohwnd nohwnd force-pushed the fix-redirect-validation branch from 0c9bdca to cb7d691 Compare May 14, 2026 11:06
@nohwnd nohwnd changed the title Fail validation when binding redirect points to missing DLL [fix] Harden binding redirect validation to catch missing DLLs May 14, 2026
@nohwnd
Copy link
Copy Markdown
Member Author

nohwnd commented May 14, 2026

/iterate

1 similar comment
@nohwnd
Copy link
Copy Markdown
Member Author

nohwnd commented May 14, 2026

/iterate

@nohwnd
Copy link
Copy Markdown
Member Author

nohwnd commented May 14, 2026


Warning

The push_to_pull_request_branch operation failed: Cannot push to fork PR: different repository names. The workflow token does not have permission to push to fork repositories.. The code changes were not applied.

Fixed the CI failure. The new validation in verify-binding-redirects.ps1 correctly caught two stale binding redirects in vstest.console/app.config that pointed to DLLs not shipped in the package layout:

  • System.Diagnostics.DiagnosticSource — explicitly excluded from the nuspec
  • System.Text.Encodings.Web — explicitly excluded from the nuspec

Removed both redirects. These were silently skipped before; now the hardened script surfaces them as errors, which is exactly what this PR is designed to do.

🔧 Iterated by PR Iteration Agent 🔧

….console

The hardened validation script caught two more orphaned binding redirects
in vstest.console/app.config — both DLLs are explicitly excluded from
the CLI package nuspec.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 14, 2026 11:43
@nohwnd
Copy link
Copy Markdown
Member Author

nohwnd commented May 14, 2026

pr is from fork, don't touch this anymore PR iterator. My bad.

- Missing-DLL errors now Write-Error instead of reporting success
- CI message distinguishes version mismatches (auto-fixable) from
  missing-DLL errors (manual removal needed)
- Addresses Copilot review comments on lines 133 and 138

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

eng/verify-binding-redirects.ps1:133

  • Missing DLLs are reported through the same $errors collection as version mismatches, so the CI failure still tells contributors to run the local auto-fix even though this case cannot be auto-fixed and requires either shipping the DLL or removing the redirect. The missing-DLL error should carry actionable remediation instead of falling through to the generic version-mismatch instructions.
                # failures (e.g. #15765). Fail so the redirect gets removed.
                # This cannot be auto-fixed — the redirect must be manually removed or the DLL shipped.
                $errors += "$($entry.ExeName): $assemblyName has a binding redirect but the DLL is not in the package layout"

Comment thread eng/verify-binding-redirects.ps1
Comment thread eng/verify-binding-redirects.ps1 Outdated
nohwnd and others added 2 commits May 14, 2026 14:04
Replace Unicode em-dash (U+2014) with ASCII hyphen in comments and
strings. The em-dash gets corrupted to multi-byte garbage on CI's
PowerShell, causing a parse error that breaks the entire validation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
It ships in the package, so allowing it would mask a future
packaging regression.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 14, 2026 14:28
Copy link
Copy Markdown
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

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread eng/verify-binding-redirects.ps1
@nohwnd nohwnd merged commit 039b7ea into microsoft:main May 14, 2026
14 of 17 checks passed
nohwnd added a commit to nohwnd/vstest that referenced this pull request May 14, 2026
…soft#15778)

* Error on binding redirects pointing to missing DLLs

Change verify-binding-redirects.ps1 to fail when a binding redirect
references a DLL that isn't in the package layout. Previously this was
silently skipped, which allowed microsoft#15765 — a redirect for
DiagnosticSource 8.0.0.1 shipped in the config but the DLL was
excluded from the package.

The whole-package-missing case (VMR) is still a skip.

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

* Remove stale DiagnosticSource and Encodings.Web redirects from vstest.console

The hardened validation script caught two more orphaned binding redirects
in vstest.console/app.config — both DLLs are explicitly excluded from
the CLI package nuspec.

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

* Fix review feedback: fail locally on missing-DLL errors

- Missing-DLL errors now Write-Error instead of reporting success
- CI message distinguishes version mismatches (auto-fixable) from
  missing-DLL errors (manual removal needed)
- Addresses Copilot review comments on lines 133 and 138

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

* Fix em-dash encoding in verify-binding-redirects.ps1

Replace Unicode em-dash (U+2014) with ASCII hyphen in comments and
strings. The em-dash gets corrupted to multi-byte garbage on CI's
PowerShell, causing a parse error that breaks the entire validation.

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

* Remove FileSystemGlobbing from allow-list

It ships in the package, so allowing it would mask a future
packaging regression.

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

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
nohwnd added a commit to nohwnd/vstest that referenced this pull request May 14, 2026
…soft#15778)

* Error on binding redirects pointing to missing DLLs

Change verify-binding-redirects.ps1 to fail when a binding redirect
references a DLL that isn't in the package layout. Previously this was
silently skipped, which allowed microsoft#15765 — a redirect for
DiagnosticSource 8.0.0.1 shipped in the config but the DLL was
excluded from the package.

The whole-package-missing case (VMR) is still a skip.

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

* Remove stale DiagnosticSource and Encodings.Web redirects from vstest.console

The hardened validation script caught two more orphaned binding redirects
in vstest.console/app.config — both DLLs are explicitly excluded from
the CLI package nuspec.

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

* Fix review feedback: fail locally on missing-DLL errors

- Missing-DLL errors now Write-Error instead of reporting success
- CI message distinguishes version mismatches (auto-fixable) from
  missing-DLL errors (manual removal needed)
- Addresses Copilot review comments on lines 133 and 138

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

* Fix em-dash encoding in verify-binding-redirects.ps1

Replace Unicode em-dash (U+2014) with ASCII hyphen in comments and
strings. The em-dash gets corrupted to multi-byte garbage on CI's
PowerShell, causing a parse error that breaks the entire validation.

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

* Remove FileSystemGlobbing from allow-list

It ships in the package, so allowing it would mask a future
packaging regression.

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

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
nohwnd added a commit that referenced this pull request May 14, 2026
* Remove DiagnosticSource binding redirect from app.configs

The binding redirect for System.Diagnostics.DiagnosticSource (8.0.0.1)
was added in #15567 but the DLL is excluded from the CLI package during
packaging. The redirect points to a version that doesn't ship, causing
MissingMethodException on net462 with DisableAppDomain=true when a test
triggers assembly resolution for DiagnosticSource.

Fixes #15765

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

* [fix] Harden binding redirect validation to catch missing DLLs (#15778)

* Error on binding redirects pointing to missing DLLs

Change verify-binding-redirects.ps1 to fail when a binding redirect
references a DLL that isn't in the package layout. Previously this was
silently skipped, which allowed #15765 — a redirect for
DiagnosticSource 8.0.0.1 shipped in the config but the DLL was
excluded from the package.

The whole-package-missing case (VMR) is still a skip.

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

* Remove stale DiagnosticSource and Encodings.Web redirects from vstest.console

The hardened validation script caught two more orphaned binding redirects
in vstest.console/app.config — both DLLs are explicitly excluded from
the CLI package nuspec.

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

* Fix review feedback: fail locally on missing-DLL errors

- Missing-DLL errors now Write-Error instead of reporting success
- CI message distinguishes version mismatches (auto-fixable) from
  missing-DLL errors (manual removal needed)
- Addresses Copilot review comments on lines 133 and 138

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

* Fix em-dash encoding in verify-binding-redirects.ps1

Replace Unicode em-dash (U+2014) with ASCII hyphen in comments and
strings. The em-dash gets corrupted to multi-byte garbage on CI's
PowerShell, causing a parse error that breaks the entire validation.

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

* Remove FileSystemGlobbing from allow-list

It ships in the package, so allowing it would mask a future
packaging regression.

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

---------

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

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
nohwnd added a commit that referenced this pull request May 14, 2026
* Remove DiagnosticSource binding redirect from app.configs

The binding redirect for System.Diagnostics.DiagnosticSource (8.0.0.1)
was added in #15567 but the DLL is excluded from the CLI package during
packaging. The redirect points to a version that doesn't ship, causing
MissingMethodException on net462 with DisableAppDomain=true when a test
triggers assembly resolution for DiagnosticSource.

Fixes #15765

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

* [fix] Harden binding redirect validation to catch missing DLLs (#15778)

* Error on binding redirects pointing to missing DLLs

Change verify-binding-redirects.ps1 to fail when a binding redirect
references a DLL that isn't in the package layout. Previously this was
silently skipped, which allowed #15765 — a redirect for
DiagnosticSource 8.0.0.1 shipped in the config but the DLL was
excluded from the package.

The whole-package-missing case (VMR) is still a skip.

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

* Remove stale DiagnosticSource and Encodings.Web redirects from vstest.console

The hardened validation script caught two more orphaned binding redirects
in vstest.console/app.config — both DLLs are explicitly excluded from
the CLI package nuspec.

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

* Fix review feedback: fail locally on missing-DLL errors

- Missing-DLL errors now Write-Error instead of reporting success
- CI message distinguishes version mismatches (auto-fixable) from
  missing-DLL errors (manual removal needed)
- Addresses Copilot review comments on lines 133 and 138

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

* Fix em-dash encoding in verify-binding-redirects.ps1

Replace Unicode em-dash (U+2014) with ASCII hyphen in comments and
strings. The em-dash gets corrupted to multi-byte garbage on CI's
PowerShell, causing a parse error that breaks the entire validation.

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

* Remove FileSystemGlobbing from allow-list

It ships in the package, so allowing it would mask a future
packaging regression.

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

---------

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.

2 participants