A Mono AOT compiler MSBuild binlog capture and replay analyzer.
The tool works by looking for known Mono AOT compiler invocations (in various flavors) in an MSBuild binlog.
The tool currently supports binlogs produced on macOS, Linux and Windows (using the dotnet CLI or msbuild
from the CLI, or Visual Studio 2022 or later) for the following project types in .NET 8 or later:
- browser WebAssembly
- Android
(Both of the above use the MonoAOTCompiler
task from dotnet/runtime)
Additionally support is planned for ios, tvOS and MacCatalyst binlogs (using the AOTCompile
task from xamarin/xamarin-macios)
In all cases rather than finding the exact mono-aot-cross
invocation, the tool instead collects the parameters and files that serve as inputs to the AOT task and stores them in a .zip file together
with a replay.proj
file. The Replay
target of the project file loads the task (also saved in the zip file) and executes it. The project fragment uses adjusted file paths so that everything (input assemblies, toolchains, etc) comes from the zipfile contents.
-
Close Visual Studio
-
Open a "Developer PowerShell for VS 2022" (or whatever version you're using)
-
Set the following environment variables and then run `devenv.exe:
$env:MSBuildDebugEngine = "1" $env:MSBUILDDEBUGPATH = "C:\Temp" devenv.exe
(you can use another directory for the debug path)
-
Clean, then build or publish your solution
-
Find the binlog in the temp directory that corresponds to your build. Usually the binlog with the latest timestamp.
-
Run
monostump
on that log
Note to replay a project captured from Visual Studio, it is necessary to run msbuild replay.proj
(not dotnet replay.proj
) Since the captured AOT compiler task is targeted for .NET Framework, not modern .NET
WARNING tool isn't stable yet. no guarantees it won't delete all your files.
$ dotnet tool install -g lambdageek.monostump --prerelease
This will install the tool in ~/.dotnet/tools
which should be on your PATH
. You can then run the tool as monostump
.
Build and install the tool:
$ dotnet pack
$ dotnet tool install -g lambdageek.monostump --prerelease --add-source ./artifacts/package/release
$ dotnet tool uninstall -g lambdageek.monostump
Description:
Scrapes an MSBuild binlog file for Mono AOT compiler invocations and creates a replayable build.
Usage:
monostump <binlog> [options]
Arguments:
<binlog> The path to the binlog file to scrape.
Options:
-?, -h, --help Show help and usage information
--version Show version information
-v, --verbose Print verbose output
-o, --output The name of the output file [default: replay.zip]
-n, --dry-run Don't write the output file
-
Compile your project and create a binlog. For example, here is a .NET 8.0 blazor-wasm project:
$ mkdir ReplayInput $ cd ReplayInput $ dotnet new blazorwasm -f net8.0 $ dotnet publish -p:PublishTrimmed=true -p:RunAOTCompilation=true -bl
-
Run the tool on the generated msbuild.binlog:
$ monostump msbuild.binlog -o ./out/replay.zip ... Archived to ./out/replay.zip
-
Send the
replay.zip
to another computer (of the same architecture) or move it to another directory$ mkdir -p /tmp/replay-example $ cp ./out/replay.zip /tmp/replay-example $ cd /tmp/replay-example $ unzip -q replay.zip
-
Use
dotnet build replay.proj
to re-run the AOT compiler task exactly how it was invoked in the original build$ dotnet run replay.proj -p:ReplayOutputPath=./replay-output ...
-
The resulting AOT outputs should be identical:
$ diff .../ReplayInput/obj/Release/net8.0/wasm/for-publish/ReplayInput.dll.bc ./replay-output/aot-output/ReplayInput.dll.bc $ echo $? 0