Skip to content

NativeAOT: Use lib prefix by default on Unix for native library outputs#124611

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/use-lib-prefix-default-unix
Draft

NativeAOT: Use lib prefix by default on Unix for native library outputs#124611
Copilot wants to merge 2 commits intomainfrom
copilot/use-lib-prefix-default-unix

Conversation

Copy link
Contributor

Copilot AI commented Feb 19, 2026

Description

On Unix, the lib prefix (e.g., libfoo.so, libfoo.dylib, libfoo.a) is the standard convention for shared and static libraries. Previously, NativeAOT only applied this prefix when the internal _UseNativeLibPrefix property was explicitly set — Android tests required it, but other Unix targets didn't get it by default.

This change makes the lib prefix the default for non-executable NativeAOT outputs on all non-Windows targets, and introduces a public UseNativeLibPrefix property for opting out.

Changes

  • Microsoft.NETCore.Native.targets: Add public UseNativeLibPrefix property defaulting to true on non-Windows. Replace the private _UseNativeLibPrefix check in the NativeBinaryPrefix condition with the new property (the _targetOS != 'win' guard is preserved so Windows builds are unaffected even with an explicit opt-in).
  • eng/testing/tests.android.targets: Remove the now-redundant <_UseNativeLibPrefix>true</_UseNativeLibPrefix> — the default behavior covers this.

Opt-out

Projects that need to suppress the prefix can set:

<UseNativeLibPrefix>false</UseNativeLibPrefix>

Changes to public API surface

None — MSBuild property changes only. UseNativeLibPrefix is the new public opt-out property.

Testing

Existing Android NativeAOT test infra validates the lib-prefixed output; no behavior change there. The main impact is that Unix NativeAOT library outputs now follow the platform convention by default.

Original prompt

This section details on the original issue you should resolve

<issue_title>Use correct native lib prefix in native AOT for android</issue_title>
<issue_description>#118299 introduced _UseNativeLibPrefix as an underscored property. Looks like android may need to set this: dotnet/android#10822.

At the time we didn't want to change the default to avoid breaking existing scenarios, but I wonder - could we try using the lib prefix by default on unix and take this breaking change? AFAIK this is a very common convention on unix so it would probably be a good default.

We could also introduce a public property to allow opting out for scenarios that don't want this.

@jtschuster @MichalStrehovsky </issue_description>

<agent_instructions>Use the native 'lib' prefix by default on unix.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

…ibPrefix opt-out

Co-authored-by: sbomer <787361+sbomer@users.noreply.github.com>
Copilot AI changed the title [WIP] Use correct native lib prefix in native AOT for Android NativeAOT: Use lib prefix by default on Unix for native library outputs Feb 19, 2026
Copilot AI requested a review from sbomer February 19, 2026 18:47
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib
See info in area-owners.md if you want to be subscribed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Use correct native lib prefix in native AOT for android

2 participants

Comments