Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Format:.NET single-file bundle

From ReverseEngineering.wiki
Format
Developer Microsoft (.NET Foundation), .NET Core 3.0 (2019)-
Magic 8B 12 02 B9 6A 61 20 38 72 7B 93 02 14 D7 A0 32 13 F5 B9 E6 EF AE 33 18 EE 3B 2D CE 24 B3 6A AE (marker in the host), preceded by the int64 manifest offset
Extensions .exe (Windows), no extension (Linux, macOS)
Endianness little
On this wiki Facts · Code · Notes · Topics

Container that `dotnet publish -p:PublishSingleFile=true` (.NET Core 3.0 and later) appends to the native apphost: the app's assemblies, native libraries and JSON config files, optionally deflate-compressed, followed by a manifest; a 32-byte marker inside the host holds the manifest's file offset. The assemblies inside are ordinary Format:.NET metadata (ECMA-335) PE files and can be extracted without running the program.

Identification

  • The executable is a native program (no CLR header) built from Microsoft's apphost (framework-dependent apps) or singlefilehost (self-contained apps, with the runtime linked in). Both contain a 40-byte placeholder: an int64 bundle header offset followed by the 32-byte marker 8B 12 02 B9 ... 6A AE, the SHA-256 of the text ".net core bundle" plus a newline (Fact:.NET single-file bundle/signature/Bundle marker). The offset is 0 in a plain apphost and the file offset of the bundle manifest in a single-file app.
  • Every apphost also contains the ASCII strings c3ab8ff13720e8ad9047dd39466b3c89 and 74e592c2fa383d4a3960714caef0c4f2, the two halves of SHA-256("foobar"): the full 64-character string is the placeholder that dotnet build overwrites with the path of the app's DLL (up to 1024 UTF-8 bytes), so a built apphost keeps only the separate halves (Fact:.NET single-file bundle/string/Apphost DLL-name placeholder). Apphosts of SDK 9 and 10 also carry a second placeholder 19ff3e9c3602ae8e841925bb461a0adb064a1f1903667a5e0d87e8f608f425ac (the .NET install search options).
  • A non-bundled apphost foo.exe loads foo.dll next to it: analyse the DLL, not the exe.
  • The marker bytes also occur as data in tools that look for bundles (ILSpy's ICSharpCode.Decompiler.dll, a Unity Hub CLI binary): check that the offset before it points inside the file at a header with version 1.0, 2.0 or 6.0.
  • Overview of this and other bundled-runtime containers (PyInstaller, Electron, Node.js SEA, pkg, nexe): Technique:Bundled-runtime applications.

Layout

Part Contents
Host image the apphost/singlefilehost PE or ELF, unchanged except for the placeholders
Embedded files assemblies aligned to 4096 bytes on Windows and on Linux/macOS ARM64 (16384 on LoongArch64, 64 elsewhere), other files unaligned; each raw or raw-DEFLATE compressed
Bundle header uint32 major, uint32 minor, int32 file count, bundle id (length-prefixed string); from version 2: deps.json offset/size, runtimeconfig.json offset/size (int64 each), uint64 flags (Fact:.NET single-file bundle/struct/Bundle header)
Manifest one entry per file: int64 offset, int64 size, int64 compressed size (version 6 only, 0 = stored), uint8 type, relative path (Fact:.NET single-file bundle/struct/Bundle file entry)

Strings (bundle id, paths) carry a 7-bit-encoded length prefix (one byte below 128, else two bytes, low 7 bits first), as written by .NET's BinaryWriter.Write(string); the host rejects longer prefixes. File types: 0 unknown, 1 assembly, 2 native binary, 3 deps.json, 4 runtimeconfig.json, 5 symbols. The header and manifest are written after the files, so the manifest is near the end of the executable.

Versions

Bundle version Written for Notes
1.0 .NET Core 3.x every file extracted to a temp directory at start-up
2.0 .NET 5 header adds deps.json/runtimeconfig.json locations and flags; assemblies loaded from the bundle in memory
6.0 .NET 6 and later file entries add the compressed size (EnableCompressionInSingleFile)

Flags bit 0 (netcoreapp3_compat_mode, IncludeAllContentForSelfExtract) means all files are bundled and extracted, as in 3.x. The bundle id is a 12-character Base64Url prefix of the manifest hash in the current bundler; 32-character ids ending in = occur in bundles of older SDKs. Unverified: which SDK changed the id length; compare bundles published with SDK 6, 7 and 8.

Extraction

Code:.NET metadata (ECMA-335)/dotnetmd (Python) lists and extracts a bundle without running it: python dotnetmd.py app.exe --bundle --extract outdir. Compressed entries are raw DEFLATE (zlib wbits=-15). The extracted assemblies are normal managed PEs; tools such as ILSpy and dnSpyEx also open bundles directly. Tested on five bundles found among installed programs (version 6.0, 3 to 425 files, one with 416 compressed entries): every file inflated to its stated size and all 83 assemblies of the compressed one parsed.

Code & repositories

  • https://github.com/dotnet/runtime @ d80abfc4b04f85722596e8d83af7f9a61dcf49da · license: MIT
    The .NET runtime (MIT): CoreCLR, the host (apphost, singlefilehost, single-file bundle reader in src/native/corehost/bundle), the bundler (src/installer/managed/Microsoft.NET.HostModel), ReadyToRun definitions (src/coreclr/inc/readytorun.h), System.Reflection.Metadata, and the format specs docs/design/specs/PE-COFF.md (debug directory entries of managed PEs) and PortablePdb-Metadata.md.
    Tested on: Sparse checkout of the files cited on the format pages at this commit (October 2026). The bundle layout was confirmed on five installed single-file apps, the ReadyToRun header on the .NET 8/9/10 shared frameworks, the Portable PDB checksum and PDB-id rules on 1854 SDK assemblies. The comment in bundle_marker.c says the marker is SHA-256 of '.net core bundle'; it is the hash of that text plus a newline. · checked 2026-10-17; last activity 2026-10-17

Evidence & references

  • dotnet/runtime at commit d80abfc4b04f85722596e8d83af7f9a61dcf49da: src/native/corehost/apphost/bundle_marker.c lines 9-41 (placeholder and marker), src/native/corehost/bundle/header.h 26-70 and header.cpp 11-46 (header, accepted versions 2.0 and 6.0), file_entry.h 24-32 and file_entry.cpp 17-48 (entry), file_type.h 19-28, reader.cpp 53-78 (path length), extractor.cpp 133-136 (raw inflate), src/installer/managed/Microsoft.NET.HostModel/Bundle/Bundler.cs 28, 111-136, 242-248, 438-444, TargetInfo.cs 32-81 (versions and alignment), Manifest.cs 77 and 148-178, src/native/corehost/apphost/apphost.c 40-71 and AppHost/HostWriter.cs 21-31 (placeholders).
  • Observed in the apphost and singlefilehost templates of .NET 8.0.30, 9.0.19 and 10.0.11 (win-x86, win-x64, win-arm64) and in 158 apphost-based executables among the programs installed on a Windows 11 machine (October 2026).