Specifying <RuntimeIdentifier> breaks the directory layout of native libraries.
- Dominant language
- C#
- Stars
- 3.2k
- Forks
- 1.3k
- PR merge metrics
- PR metrics pending
Description
We have an internal package that has some plugin native .dlls which are located in a `plugins/` subdirectory .
If you set `win-x64`, all assemblies will be copied at the root of the output directory without the `plugins\` directory which breaks the initial layout.
When `RuntimeIdentifier` is not set the layout is preserved:
But with the drawback of copying the .dll for all RIDs.
### To Reproduce
The issue is very easy to reproduce but the package is hosted in an internal package manager so I can't provide a sample😿
### Results of my investigation
When you set `win-x64` in `.csproj` it's adding the following entry in `projects.assets.json`:
```json
"net8.0/win-x64": {
"RTPal.Bridge/2.9.10": {
"type": "package",
"dependencies": {
"RTPal.Bridge.Core": "[2.9.10]"
}
},
"RTPal.Bridge.Core/2.9.10": {
"type": "package",
"compile": {
"lib/net6.0/RTPal-Bridge.dll": {
"related": ".pdb"
}
},
"runtime": {
"lib/net6.0/RTPal-Bridge.dll": {
"related": ".pdb"
}
},
"native": {
"runtimes/win-x64/native/Plugins/RTPal-AzurePlugin-x64.dll": {},
"runtimes/win-x64/native/Plugins/RTPal-S3Plugin-x64.dll": {},
"runtimes/win-x64/native/RTPal-x64.dll": {},
"runtimes/win-x64/native/RTPal-x64.pdb": {}
},
"build": {
"build/RTPal.Bridge.Core.targets": {}
}
}
}
```
When running `ResolvePackageAssets` task it will call `WriteNativeLibraries`:
https://github.com/dotnet/sdk/blob/26bbbd92e5a3cc58037e696147fa25e03e68e3a8/src/Tasks/Microsoft.NET.Build.Tasks/ResolvePackageAssets.cs#L1354-L1364
That does not pass a `destinationSubDirectory` to `WriteCopyLocalMetadataIfNeeded`.
We should for instance pass `Plugins/` when the input path is `runtimes/win-x64/native/Plugins/RTPal-AzurePlugin-x64.dll`.
### Further technical details
details of dotnet --info
SDK .NET :
Version: 9.0.301
Commit: a596cd22e2
Workload version: 9.0.300-manifests.e7e881d1
MSBuild version: 17.14.5+edd3bbf37
Environnement d'exécution :
OS Name: Windows
OS Version: 10.0.26100
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\9.0.301\
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.