I am attempting to pre-jit/Ahead-Of-Time (AOT) compile a .NET Core 5 Library to a Native Image using Microsoft's CrossGen utility as described here to improve start up time.
However the instructions for Getting CrossGen are vague:
If you install CoreCLR using a NuGet package, you can find CrossGen in the tools folder of the NuGet package.
How do I install CrossGen via NuGet?
What I've tried so far:
Create a build script that writes
deleteme.csproj
to disk and has a<PackageReference Include="Microsoft.NETCore.App.Runtime.win-x64" Version="3.1.6" />
Run
dotnet restore deleteme.csproj
. This will download the Crossgen nuget package to local cache.I can now run
~/.nuget/packages/microsoft.netcore.app.runtime.win-x64\3.1.6\tools\crossgen.exe
NOTE: I know I can use the ReadyToRun feature for Self-Contained Deployment executable (as described here) HOWEVER I need to optimize a Class Library, so ReadyToRun doesn't work.
Problem
Internal implementation package not meant for direct consumption. Please do not reference directly. 2. Installation like this seems incorrect. I'd expect CrossGen to be installed as a dotnet tool rather than needing to create a dummy project and run
dotnet restore
in order to download a copy of a nuget package in cache.
Is there a correct way to pre-jit a .NET Core 5 Library during a ci/cd build?