NativeAOT: Use lib prefix by default on Unix for native library outputs#124611
Draft
NativeAOT: Use lib prefix by default on Unix for native library outputs#124611
lib prefix by default on Unix for native library outputs#124611Conversation
…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 Feb 19, 2026
lib prefix by default on Unix for native library outputs
Remove $(LibPrefix) from mscordaccore_universal AssemblyName and let NativeBinaryPrefix handle the prefix consistently, avoiding the double-prefix (liblibmscordaccore_universal.so) that broke bootstrapped CI builds. Add $(NativeBinaryPrefix) to all path constructions in native-library.targets, Microsoft.NETCore.Native.Publish.targets, and Microsoft.NETCore.Native.Unix.targets so strip/copy/install steps use the correct prefixed filename. Opt out of UseNativeLibPrefix in SharedLibrary and CustomMainWithStubExe tests whose C++ drivers derive the library path from argv[0] via dlopen.
# Conflicts: # src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Publish.targets
Contributor
|
Added When you commit this breaking change:
Tagging @dotnet/compat for awareness of the breaking change. |
This was referenced Mar 7, 2026
src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets
Outdated
Show resolved
Hide resolved
Remove the explicit UseNativeLibPrefix default property and instead check != 'false' on the NativeBinaryPrefix condition. The _targetOS != 'win' guard on NativeBinaryPrefix already prevents the prefix on Windows, making the separate default-setting line redundant.
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.
Description
On Unix, the
libprefix (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_UseNativeLibPrefixproperty was explicitly set — Android tests required it, but other Unix targets didn't get it by default.This change makes the
libprefix the default for non-executable NativeAOT outputs on all non-Windows targets, and introduces a publicUseNativeLibPrefixproperty for opting out.Changes
Microsoft.NETCore.Native.targets: Add publicUseNativeLibPrefixproperty defaulting totrueon non-Windows. Replace the private_UseNativeLibPrefixcheck in theNativeBinaryPrefixcondition 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:
Changes to public API surface
None — MSBuild property changes only.
UseNativeLibPrefixis 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
🔒 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.