Home

crossgen2

Crossgen2 is a tool in the .NET runtime toolchain used to ahead-of-time compile managed assemblies into native-ready code, creating ReadyToRun images that improve startup performance by reducing the JIT compilation workload at application start. Introduced as the successor to the legacy crossgen, crossgen2 is designed to work with the CoreCLR runtime across Windows, Linux, and macOS and to better support large framework dependencies and multi-targeting scenarios.

It analyzes the intermediate language, metadata, and commonly used code paths to emit architecture-specific native code

Crossgen2 is typically used as part of the application's publish or prebuild process, rather than at runtime.

Implementation and scope: Crossgen2 is part of the dotnet/runtime toolchain and is maintained as open source

and
metadata
in
a
form
that
the
runtime
can
consume
at
load
time.
The
produced
ReadyToRun
images
are
stored
alongside
the
assemblies
and
are
loaded
by
the
runtime
during
startup,
reducing
the
time
spent
to
JIT
compile
hot
methods.
It
is
the
preferred
path
when
targeting
startup
time
improvements
for
client
applications
and
when
shipping
frameworks
with
ReadyToRun-compiled
images.
It
is
closely
related
to
the
ReadyToRun
feature
and
to
the
broader
family
of
ahead-of-time
options.
It
is
separate
from
NativeAOT,
which
compiles
to
a
fully
native
executable
rather
than
to
ReadyToRun
images.
by
the
.NET
community.
While
it
can
improve
startup,
it
does
not
guarantee
universal
improvements,
as
some
code
patterns
or
dynamic
features
may
be
less
amenable
to
pre-compilation.
Developers
should
test
broadly
to
ensure
compatibility
across
runtimes
and
updates.