[Java.Interop] Keep transitive System.IO.Hashing out of tool output#11969
Open
simonrozsival wants to merge 1 commit into
Open
[Java.Interop] Keep transitive System.IO.Hashing out of tool output#11969simonrozsival wants to merge 1 commit into
simonrozsival wants to merge 1 commit into
Conversation
Microsoft.SourceLink.GitHub 10.0.300 is a build-time only package (PrivateAssets="All"), but its dependency Microsoft.Build.Tasks.Git 10.0.300 brings System.IO.Hashing 10.0.8 in as a runtime asset. JI tools and libraries that reference System.IO.Hashing only transitively (class-parse, generator, jcw-gen, logcat-parse, param-name-importer, Java.Interop.Tools.Generator, Java.Interop.Tools.Maven) therefore ship a System.IO.Hashing 10.0.8 assembly. These are staged into the shared .NET for Android SDK pack tools/ directory alongside the build tasks (Xamarin.Android.Build.Tasks, Microsoft.Android.Build.BaseTasks) which reference System.IO.Hashing 10.0.9 directly. Because System.IO.Hashing bumps its AssemblyVersion on every patch (10.0.0.8 vs 10.0.0.9), the single System.IO.Hashing.dll that wins in tools/ can mismatch what the build tasks were compiled against, producing MissingMethodException on System.IO.Hashing.Crc64.Hash at build time (surfaced as error XACRP7000 from AndroidComputeResPaths via Files.HashBytes). Since these tools do not use System.IO.Hashing themselves, exclude SourceLink's runtime assets so the unused 10.0.8 assembly is never emitted. Source linking is unaffected (it runs via SourceLink build assets, not runtime assets); the build tasks keep their direct 10.0.9 reference. Note: external/xamarin-android-tools needs the same change for Xamarin.Android.Tools.AndroidSdk, which floats to 10.0.8 the same way. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adjusts Java.Interop’s shared build configuration so build-time-only SourceLink dependencies don’t leak runtime assemblies into the produced tool outputs, preventing intermittent System.IO.Hashing assembly-version collisions in the shared .NET for Android SDK tools/ directory.
Changes:
- Excludes
runtimeassets fromMicrosoft.SourceLink.GitHubvia a centralPackageReference Update=...to prevent transitiveSystem.IO.Hashingfrom being emitted. - Adds detailed in-file documentation explaining the failure mode (10.0.0.8 vs 10.0.0.9
AssemblyVersion) and why the exclusion is safe.
Show a summary per file
| File | Description |
|---|---|
| external/Java.Interop/Directory.Build.targets | Centralizes ExcludeAssets="runtime" for Microsoft.SourceLink.GitHub to keep transitive System.IO.Hashing out of tool outputs and avoid runtime assembly conflicts. |
Copilot's findings
- Files reviewed: 1/1 changed files
- Comments generated: 0
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.
Problem
Microsoft.SourceLink.GitHub10.0.300 is a build-time-only package (referenced withPrivateAssets="All"), but its dependencyMicrosoft.Build.Tasks.Git10.0.300 pullsSystem.IO.Hashing10.0.8 in as a runtime asset.JI tools/libraries that reference
System.IO.Hashingonly transitively (via SourceLink) therefore ship aSystem.IO.Hashing10.0.8 assembly:class-parse,generator,jcw-gen,logcat-parse,param-name-importerJava.Interop.Tools.Generator,Java.Interop.Tools.MavenThese are staged into the shared .NET for Android SDK pack
tools/directory alongside the build tasks (Xamarin.Android.Build.Tasks,Microsoft.Android.Build.BaseTasks), which referenceSystem.IO.Hashing10.0.9 directly.System.IO.Hashingbumps its AssemblyVersion every patch (10.0.0.8vs10.0.0.9), so the singleSystem.IO.Hashing.dllthat wins intools/can mismatch what the build tasks were compiled against, producing at build time:Because
AndroidComputeResPathsruns in every app build, this breaks the affected builds (observed intermittently on Windows CI lanes — the failure depends on whichSystem.IO.Hashing.dllcopy wins in the sharedtools/directory).The existing
<PackageReference Update="System.IO.Hashing" Version="10.0.9" />pins do not cover these projects, becauseUpdate=only applies to packages a project references directly — these projects reference it only transitively.Fix
These tools do not use
System.IO.Hashingthemselves — it only rides in as an unused runtime asset of build-time SourceLink. Exclude SourceLink's runtime assets so the unused assembly is never emitted:Verified locally: with this change,
System.IO.Hashingresolves to the emptylib/**/_._placeholder (no runtime DLL) for the affected exes and libraries (bothnet10.0andnetstandard2.0).build/buildTransitiveassets, notruntimeassets.System.IO.Hashingare unaffected —Microsoft.Android.Build.BaseTaskshas a direct<PackageReference Include="System.IO.Hashing" />(→ 10.0.9), which anExcludeAssetson SourceLink does not touch.Follow-up
external/xamarin-android-toolsneeds the same change forXamarin.Android.Tools.AndroidSdk, which floats toSystem.IO.Hashing10.0.8 by the identical transitive-SourceLink path. That is a separate upstream (dotnet/xamarin-android-tools) change + submodule bump.Notes
This is a pre-existing, latent issue on
main(not specific to any feature branch); the version-pin files are unchanged. It surfaces intermittently depending ontools/-directory copy order.