Repository navigation
Description
[Breaking change]: NativeAOT uses lib prefix by default for native library outputs on Unix
Description
Starting in .NET 11 Preview 3, NativeAOT now applies the lib prefix (e.g., libfoo.so, libfoo.dylib, libfoo.a) by default to non-executable native library outputs on Unix platforms. This aligns with standard Unix naming conventions for shared and static libraries. Previously, the lib prefix was not applied by default.
This change introduces a new public property, UseNativeLibPrefix, which allows developers to opt out of the default behavior. By default, the lib prefix is applied unless UseNativeLibPrefix is explicitly set to false.
Version
.NET 11 Preview 3
Previous behavior
On Unix platforms, NativeAOT did not apply the lib prefix to native library outputs. For example:
- A shared library output would be named
foo.soinstead oflibfoo.so. - A static library output would be named
foo.ainstead oflibfoo.a.
New behavior
NativeAOT now applies the lib prefix by default to non-executable native library outputs on Unix platforms. For example:
- A shared library output is now named
libfoo.soinstead offoo.so. - A static library output is now named
libfoo.ainstead offoo.a.
Developers can opt out of this behavior by setting the new public UseNativeLibPrefix property to false in their project file:
<PropertyGroup>
<UseNativeLibPrefix>false</UseNativeLibPrefix>
</PropertyGroup>Type of breaking change
- Behavioral change: Existing binaries might behave differently at runtime due to the change in naming conventions for native library outputs.
Reason for change
The lib prefix is a widely accepted naming convention for shared and static libraries on Unix platforms. This change improves consistency and interoperability with other Unix-based tools and systems. It also simplifies the configuration process by making the lib prefix the default behavior, reducing the need for workarounds in .NET for Android, which requires binaries to follow this naming convention.
Recommended action
Developers targeting Unix platforms with NativeAOT should review their build outputs and update any scripts, deployment processes, or configurations that depend on the previous naming conventions. Specifically:
- Update scripts and tools: If your build or deployment scripts reference native library outputs by name, ensure they account for the new
libprefix. - Opt out if necessary: If the
libprefix causes issues in your workflow, set theUseNativeLibPrefixproperty tofalsein your project file to revert to the previous behavior.
For example, to disable the lib prefix:
<PropertyGroup>
<UseNativeLibPrefix>false</UseNativeLibPrefix>
</PropertyGroup>Feature area
- NativeAOT-coreclr
Affected APIs
This change does not directly affect public APIs but introduces the following new MSBuild property:
UseNativeLibPrefix(public property)
Additional information
For more details, see the original pull request: NativeAOT: Use lib prefix by default on Unix for native library outputs.
Metadata
Metadata
Labels
Type
Projects
- StatusShow more project fields✅ Done
Activity
Add breaking change article: NativeAOT uses lib prefix on Unix in .NE…
Expect NativeAOT lib prefix on Unix for .NET 11 SDK