You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SNI package does not respect RuntimeIdentifier property #2671
When assigning a specific RuntimeIdentifier during publish, NuGet packages are supposed to only copy the required DLLs for the affected platforms/runtimes.
For example, if I specify win-x64 as the RID, I should not expect to see x86 and arm versions of DLLs in the output.
However, the Microsoft.Data.SqlClient.SNI package does not respect that, and always copies all of the native versions to the target output folder, namely:
Microsoft.Data.SqlClient.SNI.x86.dll
Microsoft.Data.SqlClient.SNI.x64.dll
Microsoft.Data.SqlClient.SNI.arm64.dll
This creates unnecessary clutter in my applications, increasing the deployment package size.
To reproduce
Create a brand new console application.
Add a dependency to either Microsoft.Data.SqlClient or Microsoft.Data.SqlClient.SNI packages.
publish the project using RID win-x64
Observe x86 and amd64 native dependencies in the output
Expected behavior
Only the DLLs that match the runtime/architecture of the project should be present in the output if the setting is explicitly defined. It should only contain all possibilities if publishing without any specific architecture in mind.
Further technical details
N/A
Additional context
I believe this issue exists because the package does not declare its native dependencies using the proper RID folder structure, and instead follows what seems to be a completely custom approach to copying the native dependencies.
It looks to me that moving to the intended runtime folder with the runtime identifiers inside would be the way to go. Here is another dependency we use that uses that format:
The SNI package is designed to load all DLLs during compilation and loads the applicable DLL for respective architecture at runtime in running process.
I don't understand why you still can't leverage the RuntimeIdentifier mechanism though @cheenamalhotra ...
It would still work just fine if you kept the runtime loading, since the required dll would still be there if the platform was restricted during build.
Copying alldlls always is extremely inefficient in that regard.
Can you elaborate why the team thinks it cannot leverage the platform-specific copying mechanism when that is setup?
We build and ship driver for all .NET target frameworks, including .NET Framework where native libraries don't get copied transitively. Even though .NET Runtime is advanced and has better capabilities, we are limited in what we can engineer from cross framework compatibility.
This is why all the Native SNI DLLs are copied via the .targets file in .NET Framework (same as done by Grpc.Core targets file shipped with the core package).
On .NET Runtime, we have a choice to custom ship native runtimes, but our focus is not to re-engineer existing design (as we ship from common codebase) but strengthen and migrate to Managed SNI implementation in future.
Activity
JRahnama commentedon Jul 14, 2024
@julealgon thank you for bringing this up. We will take a closer look to SNI.targets file and will get back to you.
cheenamalhotra commentedon Jan 8, 2026
Hi @julealgon
The SNI package is designed to load all DLLs during compilation and loads the applicable DLL for respective architecture at runtime in running process.
Closing this as by-design.
julealgon commentedon Jan 8, 2026
I don't understand why you still can't leverage the
RuntimeIdentifiermechanism though @cheenamalhotra ...It would still work just fine if you kept the runtime loading, since the required
dllwould still be there if the platform was restricted during build.Copying all
dlls always is extremely inefficient in that regard.Can you elaborate why the team thinks it cannot leverage the platform-specific copying mechanism when that is setup?
cheenamalhotra commentedon Jan 8, 2026
@julealgon
We build and ship driver for all .NET target frameworks, including .NET Framework where native libraries don't get copied transitively. Even though .NET Runtime is advanced and has better capabilities, we are limited in what we can engineer from cross framework compatibility.
This is why all the Native SNI DLLs are copied via the .targets file in .NET Framework (same as done by Grpc.Core targets file shipped with the core package).
On .NET Runtime, we have a choice to custom ship native runtimes, but our focus is not to re-engineer existing design (as we ship from common codebase) but strengthen and migrate to Managed SNI implementation in future.
julealgon commentedon Jan 8, 2026
I see. Thanks for the explanation @cheenamalhotra .
That seems exciting. Looking forward to that.