feat: Support NativeAOT static linking on Linux and macOS#38
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Enable Unix NativeAOT “single-binary” publishing by shipping and linking against a static libminipty_unix.a (instead of relying on a deployed .so/.dylib) when PublishAot=true, while keeping the existing shared-library path for non-AOT scenarios.
Changes:
- Build and package
libminipty_unix.afor Linux/macOS and require it during packing. - Add transitive MSBuild targets to link the static archive for NativeAOT on Linux/macOS and remove Unix native artifacts from publish output in that mode.
- Update CI to build Unix native artifacts and assert NativeAOT sample publish outputs contain no
libminipty_unix.so/.dylib/.a.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/MiniPty/MiniPty.csproj | Packs *.a runtime assets and includes buildTransitive/MiniPty.targets; avoids publishing the shared library when static linking is enabled. |
| scripts/pack-with-native.sh | Requires Unix static archives to exist before packing and validates they’re present in the produced nupkg. |
| scripts/build-native.sh | Builds libminipty_unix.a alongside the shared library for Linux/macOS. |
| Directory.Build.targets | Imports the repo-local buildTransitive/MiniPty.targets to exercise the same behavior in-repo (e.g., CI sample publish). |
| Directory.Build.props | Bumps version to 1.2.0. |
| buildTransitive/MiniPty.targets | Enables static linking for NativeAOT on Linux/macOS and removes Unix native artifacts from publish output when static linking is active. |
| .github/workflows/build.yaml | Builds Unix native artifacts before NativeAOT sample publish and asserts publish output excludes Unix libminipty_unix artifacts. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Enable single-binary NativeAOT publish on Unix by statically linking
libminipty_unixinstead of shipping a shared library.libminipty_unix.aalongside.so/.dylibinscripts/build-native.shand include it in the NuGet packagebuildTransitive/MiniPty.targetsto link the static archive whenPublishAot=trueon Linux/macOS (DirectPInvoke,-lutil), and exclude.so/.dylib/.afrom publish outputscripts/pack-with-native.shlibminipty_unixshared library or archive (macOS still shipsminipty_spawn_helper)Windows is unchanged (ConPTY is in-process). Bump version to 1.2.0.