Skip to content

Fix NativeAOT ILC failure on android#126213

Closed
sbomer wants to merge 2 commits intodotnet:mainfrom
sbomer:fix-aot-assettype
Closed

Fix NativeAOT ILC failure on android#126213
sbomer wants to merge 2 commits intodotnet:mainfrom
sbomer:fix-aot-assettype

Conversation

@sbomer
Copy link
Copy Markdown
Member

@sbomer sbomer commented Mar 27, 2026

By assigning correct asset type to non-DLL runtime files.

The _AddRuntimeLibsToPublishAssets target was setting AssetType="runtime" on all files from RuntimeFiles and LibrariesRuntimeFiles, including .pdb, .so, .dbg, and .dwarf files. The SDK's _ComputeAssembliesToPostprocessOnPublish uses AssetType="runtime" to stamp PostprocessAssembly=true, which caused these non-PE files to be passed as -r: references to ILC, resulting in BadImageFormatException: Unknown file format.

Only .dll files should be classified as AssetType="runtime" (managed assemblies). All other extensions are now classified as AssetType="native".

Fixes #126117

…o non-DLL runtime files

The _AddRuntimeLibsToPublishAssets target was setting AssetType="runtime"
on all files from RuntimeFiles and LibrariesRuntimeFiles, including .pdb,
.so, .dbg, and .dwarf files. The SDK's _ComputeAssembliesToPostprocessOnPublish
uses AssetType="runtime" to stamp PostprocessAssembly=true, which caused
these non-PE files to be passed as -r: references to ILC, resulting in
BadImageFormatException: Unknown file format.

Only .dll files should be classified as AssetType="runtime" (managed
assemblies). All other extensions are now classified as AssetType="native".

Fixes dotnet#126117
Copilot AI review requested due to automatic review settings March 27, 2026 17:53
@sbomer
Copy link
Copy Markdown
Member Author

sbomer commented Mar 27, 2026

/azp run runtime-extra-platforms

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @agocke, @jeffschwMSFT, @elinor-fung
See info in area-owners.md if you want to be subscribed.

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

Adjusts mobile merged-runner publish asset classification so NativeAOT/ILC only treats managed assemblies as runtime assets, preventing non-PE runtime files from being passed as -r: references during publish.

Changes:

  • Split @(RuntimeFiles) / @(LibrariesRuntimeFiles) into two RuntimePackAsset sets by extension.
  • Mark only .dll files as AssetType="runtime"; mark all non-.dll files as AssetType="native".

@sbomer
Copy link
Copy Markdown
Member Author

sbomer commented Mar 27, 2026

/azp run runtime-extra-platforms

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

NativeAOT ILC: BadImageFormatException "Unknown file format" on android-x64 RuntimeTests

2 participants