Fix missing Mono.Posix.NETStandard assembly load on Windows ARM64#766
Draft
Copilot wants to merge 4 commits into
Draft
Fix missing Mono.Posix.NETStandard assembly load on Windows ARM64#766Copilot wants to merge 4 commits into
Copilot wants to merge 4 commits into
Conversation
Copilot
AI
changed the title
[WIP] Fix missing Mono.Posix.NETStandard binary for Windows ARM64
Fix missing Mono.Posix.NETStandard assembly load on Windows ARM64
Jun 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix #765
On Windows ARM64 the CLI throws
System.IO.FileNotFoundExceptionforMono.Posix.NETStandardduring file monitoring, because the package (1.0.0) ships its managed assembly only underruntimes/{rid}/lib/netstandard2.0/and provides nowin-arm64RID (onlywin-x64,win-x86,linux-*,osx); the top-levellib/isnet40-only. Sincewin-arm64's RID fallback graph iswin-arm64 → win → any(neverwin-x64/win-x86), no managed asset resolves and the assembly fails to load as soon asMono.Unix-referencing code (file collection/monitoring) is JIT compiled — even though those Unix paths never run on Windows.Changes
Lib/Utils/MonoPosixAssemblyResolver.cs— new[ModuleInitializer]that registers anAssemblyLoadContext.Default.Resolvinghandler. It fires only when default resolution fails and loads the platform-independent managedMono.Posix.NETStandard.dllfrom a runtime folder that actually ships with the app (preferringwin-arm64, thenwin-x64, etc.). No effect on platforms where the assembly already resolves.Lib/Utils/AssemblyInfo.cs— addInternalsVisibleTo("AsaTests").Tests/MonoPosixAssemblyResolverTests.cs— cover path resolution (wrong name → null, no asset → null, shipped asset → path) plus a registration/load smoke test.The resolver lives in the Lib, so both the CLI tool and consumers of the
Microsoft.CST.AttackSurfaceAnalyzerlibrary benefit.Notes
win-arm64runtime asset) was explored but rejected:GenerateDepsFilereconciles runtime targets againstproject.assets.jsonand drops RIDs the package doesn't declare, so the entry never reachesdeps.json. The runtime resolver is self-contained and independent of SDK internals.MonoPosixHelperis intentionally not required on Windows — only the managed IL needs to load; the actual P/Invokes are gated to Linux/OSX.