Describe the bug
When publishing a .NET 10 application with -r linux-x64 that references Microsoft.Data.SqlClient (transitively via Microsoft.EntityFrameworkCore.SqlServer), the publish output places the reference assembly from lib/net9.0/ at the output root instead of the Unix runtime assembly from runtimes/unix/lib/net9.0/. At runtime, the reference assembly throws PlatformNotSupportedException.
To Reproduce
- Create a .NET 10 app with a transitive dependency on
Microsoft.Data.SqlClient 7.0.1 (e.g. via Microsoft.EntityFrameworkCore.SqlServer)
- Publish with RID:
dotnet publish -c Release -r linux-x64 -o ./publish
- Run on Linux (Ubuntu 24.04, amd64):
dotnet ./publish/App.dll
- Any attempt to create a
SqlConnection throws:
System.PlatformNotSupportedException: Microsoft.Data.SqlClient is not supported on this platform.
Expected behavior
The Unix runtime assembly (runtimes/unix/lib/net9.0/Microsoft.Data.SqlClient.dll, ~1.8 MB) should be placed at the publish root, not the reference assembly (lib/net9.0/Microsoft.Data.SqlClient.dll, ~632 KB).
Evidence
dotnet run (no publish, no RID) works correctly — the runtime resolves the Unix DLL dynamically
- The
.deps.json correctly references runtimes/unix/lib/net9.0/Microsoft.Data.SqlClient.dll
- Both DLLs are present in the publish output, but the root one (632K) gets loaded instead of the unix one (1.8M)
- The package only has
net9.0 TFMs; the app targets net10.0 (TFM fallback gap may contribute)
Environment
- Microsoft.Data.SqlClient: 7.0.1
- .NET SDK: 10.0.302 (container:
mcr.microsoft.com/dotnet/sdk:10.0)
- .NET Runtime: 10.0.10
- OS: Ubuntu 24.04.4 LTS, linux-x64
- Publish command:
dotnet publish -c Release -r linux-x64 -o ./publish
Workaround
An MSBuild target that copies the Unix runtime DLL over the reference assembly after publish:
<Target Name="FixSqlClientRuntimeAssembly" AfterTargets="Publish"
Condition="$([System.String]::new('$(RuntimeIdentifier)').StartsWith('linux'))">
<PropertyGroup>
<SqlClientUnixRuntime>$(PublishDir)runtimes/unix/lib/net9.0/Microsoft.Data.SqlClient.dll</SqlClientUnixRuntime>
<SqlClientRoot>$(PublishDir)Microsoft.Data.SqlClient.dll</SqlClientRoot>
</PropertyGroup>
<Copy SourceFiles="$(SqlClientUnixRuntime)" DestinationFiles="$(SqlClientRoot)"
Condition="Exists('$(SqlClientUnixRuntime)')" />
</Target>
Related
Describe the bug
When publishing a .NET 10 application with
-r linux-x64that referencesMicrosoft.Data.SqlClient(transitively viaMicrosoft.EntityFrameworkCore.SqlServer), the publish output places the reference assembly fromlib/net9.0/at the output root instead of the Unix runtime assembly fromruntimes/unix/lib/net9.0/. At runtime, the reference assembly throwsPlatformNotSupportedException.To Reproduce
Microsoft.Data.SqlClient7.0.1 (e.g. viaMicrosoft.EntityFrameworkCore.SqlServer)dotnet publish -c Release -r linux-x64 -o ./publish
dotnet ./publish/App.dll
SqlConnectionthrows:System.PlatformNotSupportedException: Microsoft.Data.SqlClient is not supported on this platform.
Expected behavior
The Unix runtime assembly (
runtimes/unix/lib/net9.0/Microsoft.Data.SqlClient.dll, ~1.8 MB) should be placed at the publish root, not the reference assembly (lib/net9.0/Microsoft.Data.SqlClient.dll, ~632 KB).Evidence
dotnet run(no publish, no RID) works correctly — the runtime resolves the Unix DLL dynamically.deps.jsoncorrectly referencesruntimes/unix/lib/net9.0/Microsoft.Data.SqlClient.dllnet9.0TFMs; the app targetsnet10.0(TFM fallback gap may contribute)Environment
mcr.microsoft.com/dotnet/sdk:10.0)dotnet publish -c Release -r linux-x64 -o ./publishWorkaround
An MSBuild target that copies the Unix runtime DLL over the reference assembly after publish:
Related