Repository navigation
Align x86 .NET Framework compatibility overrides with x64 - #15326
Conversation
Explicitly opt out of legacy I/O quirks before managed startup. Cover WriteLinesToFile and Unzip at 291 characters in a fresh .NET 4.0 host using MSBuild's configuration and Win32 manifest. Co-authored-by: Copilot <[email protected]> Copilot-Session: 9008d8ff-eff1-4148-84d2-191cf7bbc325
There was a problem hiding this comment.
🟡 Changes recommended
The x86 regression host cannot load the x64 bootstrap executable in Platform=x64 builds.
1 open issue
What changed in this PR
Restores intended long-path behavior for x86 .NET Framework MSBuild when early CLR initialization selects legacy defaults.
Changes:
- Explicitly disables legacy path handling and long-path blocking.
- Adds 291-character path regressions for
WriteLinesToFileandUnzip. - Documents why configuration overrides must precede managed startup.
| File | Description |
|---|---|
| src/MSBuild/app.config | Adds long-path overrides while preserving the FIPS setting. |
| src/MSBuild.UnitTests/XMake_Tests.cs | Adds isolated x86 regression cases with content verification. |
| src/MSBuild.UnitTests/Microsoft.Build.CommandLine.UnitTests.csproj | Copies the manifest for the regression host. |
| documentation/NETFramework-NGEN.md | Explains early CLR compatibility initialization. |
Review effort: Balanced
Select the unqualified x86 bootstrap from the architecture-neutral root instead of using the parent test platform's executable. Explicitly skip when an x64-only build does not provide the x86 layout. Reproduced the original two BadImageFormatException failures under an x64 test host; corrected cases pass under both x86 and x64 hosts. Co-authored-by: Copilot <[email protected]> Copilot-Session: 9008d8ff-eff1-4148-84d2-191cf7bbc325
Run actual installed x86 MSBuild processes at 291 characters and record I/O switches and native-image usage. Keep the default probe read-only; offer an opt-in temporary config A/B/A comparison with exact restoration. Validate PowerShell 5.1 and 7 plus edit/restore behavior on an owned staged runtime, without changing installed VS files or native images. Co-authored-by: Copilot <[email protected]> Copilot-Session: 9008d8ff-eff1-4148-84d2-191cf7bbc325
TryGetSwitch reports whether a switch was found, not whether it came from a config override. Co-authored-by: Copilot <[email protected]> Copilot-Session: 9008d8ff-eff1-4148-84d2-191cf7bbc325
|
Note This comment was generated by GitHub Copilot CLI. Affected installed 18.12 x86: NGEN-preserving config A/B/A confirmedAn affected-machine run has now supplied the installed-process evidence that was previously missing. Both real tasks fail with the original configuration, pass with the two explicit I/O overrides, and fail again after restoration, while the same Environment and procedure
& "$env:TEMP\Test-MSBuildLongPaths.ps1" `
-MSBuildExe 'C:\Program Files\Microsoft Visual Studio\18\Insiders\MSBuild\Current\Bin\MSBuild.exe' `
-TestFixThe temporary logical configuration change was limited to these entries, preserving other overrides: No executable relocation or NGEN registration/regeneration was performed. The script reported that the original configuration was restored byte-for-byte before the final phase. Observed results
The native-image path reported in all six Original/Patched/Restored processes was identical: Failure excerpts (personal and temporary paths omitted)Original and restored Original and restored Analysis
This closes the installed-NGEN remedy-validation gap. It does not by itself identify the first bad release/commit or directly capture the first target-framework lookup; those are separate trigger/initialization investigations. |
Keep the PR scoped to the x86 defaults, regression coverage, and the compatibility note. Preserve installed A/B/A evidence as an external experiment rather than adding an installed-config editing utility. Co-authored-by: Copilot <[email protected]> Copilot-Session: 9008d8ff-eff1-4148-84d2-191cf7bbc325
|
rescoping to making parity work |
Use the same eight explicit switches as the existing x64 configuration instead of allowing premature CLR initialization to retain legacy defaults. Keep the existing FIPS setting and both long-path overrides unchanged. Cover async culture flow, cancellation registration after disposal, and independent claims-actor copying in fresh Framework 4.0 hosts. Reuse the existing architecture-safe host setup for those and the long-path cases. Fixes dotnet#15333. Co-authored-by: Copilot <[email protected]> Copilot-Session: 9008d8ff-eff1-4148-84d2-191cf7bbc325
|
Note This comment was generated by GitHub Copilot CLI. Expanded x86/x64 quirk parity and scope of #15333
The x86 configuration now exactly matches the existing eight-entry x64 The discrepancy dates to June 18, 2021, when dotnet/msbuild#6562 added the workaround only to x64. The five newly explicit Additional red/green behavior coverageThe following real BCL behavior probes run in fresh x86 processes declaring a .NET 4.0 target, with the selected production MSBuild configuration copied alongside the host:
Together with the two existing actual-task long-path cases, the focused set passes 5/5 with no skips, from both x86 and x64 parent test hosts while always selecting the x86 bootstrap/configuration. Full CLI results after alignment: 720 passed / 8 skipped on net472; 704 passed / 8 skipped on net11.0; zero failures. The default full repository build passed with only the existing NuGet audit warnings. CSP window-handle interop and portable-PDB decoding retain the longstanding x64 values and Framework-default source support; they do not have new hardware/symbol-specific end-to-end coverage here. Does this resolve #15333?Yes, for the reported Windows x86 .NET Framework The issue's original project was also run against the aligned x86 bootstrap with its XML property values checked against the report. Only an owned The PR now uses |
Remove the synthetic regression tests, generated Framework host helper, and test-project manifest wiring. Keep the installed NGEN A/B/A evidence as validation without retaining costly synthetic test scaffolding. Use the suggested documentation wording about NGEN-dependent quirk calculation and explicitly specified built-in Framework quirks. Co-authored-by: Copilot <[email protected]> Copilot-Session: 9008d8ff-eff1-4148-84d2-191cf7bbc325
|
/backport to vs18.11 |
|
Started backporting to |

Related issue(s):
Fixes #15333.
Related: #5331, #6562.
Context
NGEN can affect how .NET Framework loads assemblies and computes compatibility quirks. In some NGEN states, x86
MSBuild.exeuses legacy I/O behavior despite targeting .NET Framework 4.7.2, causing theWriteLinesToFileandUnziplong-path failures reported in #15333.The x64 configuration has explicitly specified these compatibility settings since #6562; x86 still relied on implicit defaults for most of them.
Changes Made
AppContextSwitchOverridesvalue exactly match the existing eight-entry x64 value, preserving the existing FIPS setting.Compatibility
The five non-I/O additions restore the normal .NET Framework 4.7.2 defaults; the existing FIPS override remains unchanged. The x64 and .NET configurations, task implementations, assembly bindings, NGEN registration, public APIs, and MSBuild diagnostic definitions are unchanged. No ChangeWave is needed for this restoration.
Testing
Real installed 18.12 x86 A/B/A: both tasks fail with the original config, pass with the I/O overrides, and fail again after byte-for-byte restoration, while the same
MSBuild.ni.exepath remains loaded. See the captured evidence and analysis.COMPLUS_ZapDisable=0COMPLUS_ZapDisable=1COMPLUS_ZapDisable=0COMPLUS_ZapDisable=0Every phase used 291-character output paths, a reported 4.7.2 target framework, x86, and
LongPathsEnabled=1. The issue's original project also passed against the aligned bootstrap with an ownedBaseDirectoryoverride: 350-character file, 285-character directory, contents verified, withCOMPLUS_ZapDisable=0and1.Per review feedback, the synthetic regression tests, generated-host helper, and manifest-copy wiring were removed. They do not reproduce the installed/version/NGEN-dependent trigger faithfully enough to justify retaining that scaffolding. The PR adds no automated regression test or diagnostic utility.
After removal, the affected project rebuilt successfully for both
net472andnet11.0:Both test files now match the PR base, and the eight x86/x64 override entries remain identical. Earlier local validation results remain historical evidence, not tests retained in the change set.
Dependencies and Follow-up
No package or runtime update is required. This mitigates the reported x86 .NET Framework
MSBuild.exesymptoms once the updated configuration is deployed; it does not repair the underlying CLR initialization defect or configure arbitrary custom hosts. Identifying the first trigger release/commit remains a separate investigation.