-
Notifications
You must be signed in to change notification settings - Fork 6.1k
[Breaking change]: .NET Linux applications do not look in netcoredeps sub-directory for native libraries
#45778
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
c746330
[Breaking change]: .NET Linux applications do not look in `netcoredep…
CamSoper c3d1160
lint fix
CamSoper 4210233
Review feedback from @am11
CamSoper 60ecaba
Review feedback from @jkotas
CamSoper 99340b6
period
CamSoper 7249576
Apply suggestions from code review
2ee0bc7
type of change
CamSoper 2f57437
Merge branch 'CamSoper/issue45777' of https://github.com/camsoper/dot…
CamSoper b54e1c7
another fix
CamSoper 1c569cf
Apply suggestions from code review
dc0dc5a
indent
CamSoper e7c760e
Merge branch 'CamSoper/issue45777' of https://github.com/camsoper/dot…
CamSoper 30c2aa3
fixed xrefs
CamSoper c4482f8
Merge remote-tracking branch 'upstream/main' into CamSoper/issue45777
CamSoper File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| --- | ||
| title: "Breaking change - Linux native library resolution no longer uses `netcoredeps`" | ||
| description: "Learn about the breaking change in .NET 8 where Linux applications no longer search the `netcoredeps` subdirectory for native libraries." | ||
| ms.date: 4/10/2025 | ||
| ai-usage: ai-assisted | ||
| ms.custom: https://github.com/dotnet/docs/issues/45777 | ||
| --- | ||
|
|
||
| # Linux native library resolution no longer uses `netcoredeps` | ||
|
|
||
| Starting in .NET 8, Linux applications no longer search the `netcoredeps` subdirectory for native libraries. | ||
|
|
||
| ## Version introduced | ||
|
|
||
| .NET 8 | ||
|
|
||
| ## Previous behavior | ||
|
|
||
| In earlier versions of .NET, Linux applications searched for native libraries in a `netcoredeps` subdirectory located next to the application executable. This behavior applied to all native library loads, including user-defined platform invokes (p/invokes). | ||
|
|
||
| ## New behavior | ||
|
|
||
| In .NET 8 and later, Linux applications no longer search the `netcoredeps` subdirectory for native libraries. Native library resolution now follows standard mechanisms without relying on this subdirectory. | ||
|
|
||
| ## Type of breaking change | ||
|
|
||
| This is a [source incompatible](../../categories.md#source-compatibility) change. | ||
|
|
||
| ## Reason for change | ||
|
|
||
| The `netcoredeps` behavior was originally introduced to handle complex dependencies on third-party libraries in earlier .NET versions. Modern .NET versions no longer require this behavior due to improved dependency handling. Additionally, the mechanism isn't aligned with recommended practices for ELF platforms. | ||
CamSoper marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| For more information, see [GitHub issue #114393](https://github.com/dotnet/runtime/issues/114393). | ||
|
|
||
| ## Recommended action | ||
|
|
||
| If your application relied on the `netcoredeps` subdirectory for p/invokes or custom native library resolution, use the following alternatives: | ||
|
|
||
| - Implement a custom resolution mechanism using <xref:System.Runtime.InteropServices.DllImportResolver> or the <xref:System.Runtime.Loader.AssemblyLoadContext.ResolvingUnmanagedDll> event. | ||
CamSoper marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
CamSoper marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| - If an `RPATH` is required in your deployment, modify the ELF file explicitly. | ||
CamSoper marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## Affected APIs | ||
|
|
||
| - `DllImport` | ||
| - <xref:System.Runtime.InteropServices.NativeLibrary.Load*?displayProperty=fullName> | ||
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
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.
Uh oh!
There was an error while loading. Please reload this page.