Skip to content

[build] Exclude SourceLink runtime assets to pin System.IO.Hashing - #12034

Merged
jonathanpeppers merged 1 commit into
mainfrom
dev/simonrozsival/pin-system-io-hashing
Jul 10, 2026
Merged

jonathanpeppers merged 1 commit into
mainfrom
dev/simonrozsival/pin-system-io-hashing

Conversation

@simonrozsival

Copy link
Copy Markdown
Member

Summary

Microsoft.SourceLink.GitHub is a build-time-only package (PrivateAssets="All"), but in its 10.x line its Microsoft.Build.Tasks.Git dependency pulls System.IO.Hashing in as a runtime asset (e.g. Microsoft.Build.Tasks.Git 10.0.300 → System.IO.Hashing 10.0.8). Any project that references System.IO.Hashing only transitively then ships that version into the .NET for Android SDK pack's tools/ directory, where it collides with the pinned $(SystemIOHashingPackageVersion) (currently 10.0.9) that the build tasks are compiled against.

Because System.IO.Hashing bumps its AssemblyVersion every patch (10.0.0.8 vs 10.0.0.9), the mismatched assembly produces a hard XACRP7000 / MissingMethodException: System.IO.Hashing.Crc64.Hash(...) at app build time.

Fix

Add ExcludeAssets="runtime" to the repo-wide Microsoft.SourceLink.GitHub reference in the root Directory.Build.targets, so SourceLink can never contribute a floating System.IO.Hashing runtime asset. Source linking is unaffected — it runs via SourceLink's build assets, which are untouched.

-    <PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
+    <PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" ExcludeAssets="runtime" />

This mirrors the pin already present in external/Java.Interop/Directory.Build.targets (which fixed the same float for class-parse/jcw-gen/generator after those hit it).

Why now (future-proofing)

The main repo currently references SourceLink 8.0.0, whose Microsoft.Build.Tasks.Git 8.0.0 does not depend on System.IO.Hashing — so the float isn't active on main today. But the moment the repo bumps SourceLink to 10.x (as Java.Interop already has), the transitive System.IO.Hashing 10.0.8 would reappear and reintroduce the XACRP7000 failures. This tiny, precedent-matching pin makes the repo robust against that regression.

Verification

  • dotnet restore succeeds; System.IO.Hashing still resolves to the pinned 10.0.9.
  • ExcludeAssets="runtime" only excludes runtime assets — SourceLink's build/targets assets (which perform source linking) are unaffected.
  • Change is a single attribute + explanatory comment in one file.

Microsoft.SourceLink.GitHub is a build-time only package (PrivateAssets="All"),
but in 10.x its Microsoft.Build.Tasks.Git dependency pulls System.IO.Hashing in
as a *runtime* asset (e.g. 10.0.300 -> 10.0.8). Projects that reference
System.IO.Hashing only transitively would then ship that version into the SDK
pack's `tools/` directory, where it collides with the pinned
$(SystemIOHashingPackageVersion) the build tasks are compiled against
(System.IO.Hashing bumps its AssemblyVersion every patch: 10.0.0.8 vs 10.0.0.9),
producing an XACRP7000 MissingMethodException on System.IO.Hashing.Crc64.Hash at
build time.

Add ExcludeAssets="runtime" to the repo-wide SourceLink reference so it can never
contribute a floating System.IO.Hashing. Source linking is unaffected (it runs
via SourceLink's build assets). This mirrors the pin already present in
external/Java.Interop/Directory.Build.targets and future-proofs the main repo
against a SourceLink bump to 10.x.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 527f04b6-c95a-4a66-b90f-4c52ba5496f3
Copilot AI review requested due to automatic review settings July 10, 2026 14:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 hardens the repo’s SourceLink configuration to prevent Microsoft.SourceLink.GitHub from ever contributing transitive runtime assets (notably System.IO.Hashing) into SDK/tool outputs, avoiding System.IO.Hashing assembly version mismatches that can surface as XACRP7000/MissingMethodException during app builds.

Changes:

  • Add ExcludeAssets="runtime" to the repo-wide Microsoft.SourceLink.GitHub PackageReference in Directory.Build.targets.
  • Add an explanatory comment documenting the System.IO.Hashing transitive runtime-asset failure mode and noting parity with external/Java.Interop/Directory.Build.targets.
Show a summary per file
File Description
Directory.Build.targets Excludes SourceLink runtime assets repo-wide (while keeping build assets) to prevent transitive System.IO.Hashing runtime DLLs from flowing into SDK/tool outputs.

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 0

@jonathanpeppers
jonathanpeppers merged commit 76e706c into main Jul 10, 2026
43 checks passed
@jonathanpeppers
jonathanpeppers deleted the dev/simonrozsival/pin-system-io-hashing branch July 10, 2026 22:14
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 10, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants