Skip to content

Modernize to net8.0/net10.0 and ship as a native-AOT tool - #13

Merged
Mpdreamz merged 1 commit into
masterfrom
modernize-net10-aot
Sep 2, 2026
Merged

Mpdreamz merged 1 commit into
masterfrom
modernize-net10-aot

Conversation

@Mpdreamz

@Mpdreamz Mpdreamz commented Sep 2, 2026 •

Copy link
Copy Markdown
Collaborator

assembly-rewriter targets net8.0/net10.0, ships as a self-contained native-AOT executable on five platforms, and parses its CLI with Nullean.Argh instead of CommandLineParser.

Prompt summary: Modernize this repo's build tooling the way curb, assembly-differ, and nupkg-validator already do — bump the stale target frameworks, move CLI parsing onto a source-generated parser, and package the tool as native-AOT dotnet tools per-RID with a framework-dependent fallback.

Why

The project still targeted netcoreapp3.0, netcoreapp3.1, net5.0, and net6.0 — all out of support. CommandLineParser parses arguments through reflection, which native AOT trims away, blocking the AOT packaging this PR adds. The pinned build tools, nupkg-validator 0.5.0 and assembly-differ 0.14.0, predate net8.0+ output: the old nupkg-validator throws loading this project's assembly for validation, and the old assembly-differ mis-resolves the dotted net8.0 framework folder when diffing.

What

CLI parsing

AssemblyRewriterCommand.cs replaces the CommandLineParser wiring in Program.cs with Nullean.Argh, registered via MapAndRootAlias<AssemblyRewriterCommands>() with [DefaultCommand] so the original bare invocation (no subcommand) still works. Options.cs drops its CommandLineParser attributes and becomes a plain data holder. Doc-comment-driven flag names and short aliases (-i/--in, -o/--out, -r/--resolvedir, -k/--keyfile, -m/--merge, -v/--verbose) only get picked up this way — a bare method-group Map/MapRoot delegate silently ignores them, filed as nullean/argh#74.

Target frameworks

assembly-rewriter.csproj moves from netcoreapp3.0;netcoreapp3.1;net5.0;net6.0 to net8.0;net10.0. global.json and build/scripts/scripts.fsproj follow suit, and <Nullable>enable</Nullable> is on for new code with a NoWarn list covering the legacy code that predates nullable annotations.

Native-AOT packaging

The project gains linux-x64, linux-arm64, win-x64, win-arm64, and osx-arm64 as RuntimeIdentifiers, plus a framework-dependent any fallback, with PublishAot, PublishSelfContained, and StripSymbols scoped to builds targeting a specific RID.

Package staging, signing, and CI

generatePackages stages a full dotnet pack and keeps only the root and any packages, replacing the unsigned obj/ copy of this project's own assembly that dotnet pack puts inside the any package with the correctly signed bin/ one. .github/workflows/ci.yml adds an aot-pack matrix job building each RID on a matching runner, ahead of a build job that downloads and merges the artifacts before packages get published.

Build tool pins

dotnet-tools.json bumps nupkg-validator from 0.5.0 to 0.10.1 and assembly-differ from 0.14.0 to 0.16.0.

Verify

./build.sh build generatepackages validatepackages generateapichanges -s true
dotnet tool install --add-source build/output assembly-rewriter
assembly-rewriter --in path/to/Some.dll --out path/to/Some.Rewritten.dll

…kaging

CommandLineParser's reflection-based parsing is trimmed away under NativeAOT,
so a published AOT build of the old CLI silently failed to recognize its own
arguments. Porting to Nullean.Argh (source-generated, no reflection at parse
time) unblocks AOT packaging the same way curb, assembly-differ, and
nupkg-validator already ship it: one native-AOT package per RID plus a
framework-dependent 'any' fallback, selected transparently by the root
package's DotnetToolSettings.xml.

Also bumps the pinned nupkg-validator and assembly-differ build tools to
versions that can actually validate/diff net8.0+ output (the old pins predate
those TFMs and either fail to load the assembly or mis-resolve its framework
folder), and modernizes the CI workflow with an AOT pack matrix job.

Co-authored-by: Cursor <cursoragent@cursor.com>
@Mpdreamz Mpdreamz added the enhancement New feature or request label Sep 2, 2026
@Mpdreamz Mpdreamz changed the title Modernize to net8.0/net10.0, port to Nullean.Argh, add native-AOT packaging Modernize to net8.0/net10.0 and ship as a native-AOT tool Sep 2, 2026
@Mpdreamz
Mpdreamz merged commit b103baa into master Sep 2, 2026
2 checks passed
@Mpdreamz
Mpdreamz deleted the modernize-net10-aot branch September 2, 2026 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant