Skip to content

feat: Support NativeAOT static linking on Linux and macOS#38

Merged
guitarrapc merged 9 commits into
mainfrom
static
Jul 5, 2026
Merged

feat: Support NativeAOT static linking on Linux and macOS#38
guitarrapc merged 9 commits into
mainfrom
static

Conversation

@guitarrapc

Copy link
Copy Markdown
Owner

Summary

Enable single-binary NativeAOT publish on Unix by statically linking libminipty_unix instead of shipping a shared library.

  • Build libminipty_unix.a alongside .so/.dylib in scripts/build-native.sh and include it in the NuGet package
  • Add buildTransitive/MiniPty.targets to link the static archive when PublishAot=true on Linux/macOS (DirectPInvoke, -lutil), and exclude .so/.dylib/.a from publish output
  • Require static archives in scripts/pack-with-native.sh
  • CI: assert NativeAOT sample publish on Linux/macOS contains no libminipty_unix shared library or archive (macOS still ships minipty_spawn_helper)

Windows is unchanged (ConPTY is in-process). Bump version to 1.2.0.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.a for 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.

Comment thread scripts/build-native.sh
Comment thread buildTransitive/MiniPty.targets

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Comment thread buildTransitive/MiniPty.targets Outdated
Comment thread buildTransitive/MiniPty.targets
Comment thread scripts/build-native.sh Outdated
Comment thread src/MiniPty/MiniPty.csproj

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Comment thread buildTransitive/MiniPty.targets Outdated
Comment thread buildTransitive/MiniPty.targets

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated no new comments.

@guitarrapc guitarrapc merged commit 26df003 into main Jul 5, 2026
19 checks passed
@guitarrapc guitarrapc deleted the static branch July 5, 2026 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants