Table of Contents

Class BundleManifest

Namespace
AsmResolver.DotNet.Bundles
Assembly
AsmResolver.DotNet.dll

Represents a set of bundled files embedded in a .NET application host or single-file host.

public class BundleManifest
Inheritance
BundleManifest
Derived
Inherited Members

Constructors

BundleManifest()

Initializes an empty bundle manifest.

protected BundleManifest()

BundleManifest(uint)

Creates a new bundle manifest.

public BundleManifest(uint majorVersionNumber)

Parameters

majorVersionNumber uint

The file format version.

BundleManifest(uint, string)

Creates a new bundle manifest with a specific bundle identifier.

public BundleManifest(uint majorVersionNumber, string bundleId)

Parameters

majorVersionNumber uint

The file format version.

bundleId string

The unique bundle manifest identifier.

Properties

BundleID

Gets or sets the unique identifier for the bundle manifest.

public string? BundleID { get; set; }

Property Value

string

Remarks

When this property is set to null, the bundle identifier will be generated upon writing the manifest based on the contents of the manifest.

Files

Gets a collection of files stored in the bundle.

public IList<BundleFile> Files { get; }

Property Value

IList<BundleFile>

Flags

Gets or sets flags associated to the bundle.

public BundleManifestFlags Flags { get; set; }

Property Value

BundleManifestFlags

MajorVersion

Gets or sets the major file format version of the bundle.

public uint MajorVersion { get; set; }

Property Value

uint

Remarks

Version numbers recognized by the CLR are:

  • 1 for .NET Core 3.1
  • 2 for .NET 5.0
  • 6 for .NET 6.0

MinorVersion

Gets or sets the minor file format version of the bundle.

public uint MinorVersion { get; set; }

Property Value

uint

Remarks

This value is ignored by the CLR and should be set to 0.

Methods

FindBundleManifestAddress(IDataSource)

Attempts to find the start of the bundle header in the provided file.

public static long FindBundleManifestAddress(IDataSource source)

Parameters

source IDataSource

The file to locate the bundle header in.

Returns

long

The offset, or -1 if none was found.

FromBytes(byte[])

Attempts to automatically locate and parse the bundle header in the provided file.

public static BundleManifest FromBytes(byte[] data)

Parameters

data byte[]

The raw contents of the file to read.

Returns

BundleManifest

The read manifest.

FromBytes(byte[], ulong)

Parses the bundle header in the provided file at the provided address.

public static BundleManifest FromBytes(byte[] data, ulong offset)

Parameters

data byte[]

The raw contents of the file to read.

offset ulong

The address within the file to start reading the bundle at.

Returns

BundleManifest

The read manifest.

FromDataSource(IDataSource)

Attempts to automatically locate and parse the bundle header in the provided file.

public static BundleManifest FromDataSource(IDataSource source)

Parameters

source IDataSource

The raw contents of the file to read.

Returns

BundleManifest

The read manifest.

FromDataSource(IDataSource, ulong)

Parses the bundle header in the provided file at the provided address.

public static BundleManifest FromDataSource(IDataSource source, ulong offset)

Parameters

source IDataSource

The raw contents of the file to read.

offset ulong

The address within the file to start reading the bundle at.

Returns

BundleManifest

The read manifest.

FromFile(string)

Attempts to automatically locate and parse the bundle header in the provided file.

public static BundleManifest FromFile(string filePath)

Parameters

filePath string

The path to the file to read.

Returns

BundleManifest

The read manifest.

FromReader(BinaryStreamReader)

Parses the bundle header from the provided input stream.

public static BundleManifest FromReader(BinaryStreamReader reader)

Parameters

reader BinaryStreamReader

The input stream pointing to the start of the bundle to read.

Returns

BundleManifest

The read manifest.

GenerateDeterministicBundleID()

Generates a bundle identifier based on the SHA-256 hashes of all files in the manifest.

public string GenerateDeterministicBundleID()

Returns

string

The generated bundle identifier.

GetFiles()

Obtains the list of files stored in the bundle.

protected virtual IList<BundleFile> GetFiles()

Returns

IList<BundleFile>

The files

Remarks

This method is called upon initialization of the Files property.

GetTargetRuntime()

Determines the runtime that the assemblies in the bundle are targeting.

public DotNetRuntimeInfo GetTargetRuntime()

Returns

DotNetRuntimeInfo

The runtime.

Exceptions

ArgumentException

Occurs when the runtime could not be determined.

IsBundledAssembly(IDataSource)

Gets a value indicating whether the provided data source contains a conventional bundled assembly signature.

public static bool IsBundledAssembly(IDataSource source)

Parameters

source IDataSource

The file to locate the bundle header in.

Returns

bool

true if a bundle signature was found, false otherwise.

TryGetTargetRuntime(out DotNetRuntimeInfo)

Attempts to determine the runtime that the assemblies in the bundle are targeting.

public bool TryGetTargetRuntime(out DotNetRuntimeInfo targetRuntime)

Parameters

targetRuntime DotNetRuntimeInfo

When the method returns true, contains the target runtime.

Returns

bool

true if the runtime could be determined, false otherwise.

WriteManifest(BinaryStreamWriter, bool)

Writes the manifest to an output stream.

public ulong WriteManifest(BinaryStreamWriter writer, bool isArm64Linux)

Parameters

writer BinaryStreamWriter

The output stream to write to.

isArm64Linux bool

true if the application host is a Linux ELF binary targeting ARM64.

Returns

ulong

The address of the bundle header.

Remarks

This does not necessarily produce a working executable file, it only writes the contents of the entire manifest, without a host application that invokes the manifest. If you want to produce a runnable executable, use one of the WriteUsingTemplate methods instead.

WriteUsingTemplate(BinaryStreamWriter, BundlerParameters)

Constructs a new application host file based on the bundle manifest.

public void WriteUsingTemplate(BinaryStreamWriter writer, BundlerParameters parameters)

Parameters

writer BinaryStreamWriter

The output stream to write to.

parameters BundlerParameters

The parameters to use for bundling all files into a single executable.

WriteUsingTemplate(Stream, in BundlerParameters)

Constructs a new application host file based on the bundle manifest.

public void WriteUsingTemplate(Stream outputStream, in BundlerParameters parameters)

Parameters

outputStream Stream

The output stream to write to.

parameters BundlerParameters

The parameters to use for bundling all files into a single executable.

WriteUsingTemplate(string, in BundlerParameters)

Constructs a new application host file based on the bundle manifest.

public void WriteUsingTemplate(string outputPath, in BundlerParameters parameters)

Parameters

outputPath string

The path of the file to write to.

parameters BundlerParameters

The parameters to use for bundling all files into a single executable.