Repository navigation
Closed as not planned
Closed as not planned
Copy link
Labels
External 🔗Issue is in an external component
Description
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.SqlClient7.0.1 (e.g. viaMicrosoft.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
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- The
.deps.jsoncorrectly referencesruntimes/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.0TFMs; the app targetsnet10.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
- Regression with published application: PlatformNotSupportedException #445 (Regression with published application: PlatformNotSupportedException) — closed, but still reproducing on .NET 10 / SqlClient 7.0.1
Reacted by joris-willems
Metadata
Metadata
Assignees
Labels
External 🔗Issue is in an external component
Type
Projects
- StatusShow more project fieldsDone
Activity
mahdiyar021 commentedon Jul 20, 2026
i fix this with this config :
github-actions commentedon Jul 20, 2026
🔍 Triage Summary
Area\NetcoreAnalysis
When publishing a .NET 10 app with a RID (
-r linux-x64) that takes a TFM fallback fromnet10.0→net9.0, the .NET SDK's publish asset resolution picks up thelib/net9.0/reference assembly (a stub that throwsPlatformNotSupportedException) instead ofruntimes/unix/lib/net9.0/runtime assembly. This is a NuGet/SDK publish asset selection bug at the intersection of RID-specific asset resolution and TFM fallback — the.deps.jsonis correctly generated, but the wrong DLL wins the root output slot. The affected component is the NuGet package layout and/or MSBuild publish targets in the SqlClient package. Severity: P1 — blocks all Linux/macOS publish scenarios for .NET 10 apps consuming SqlClient 7.x.Next Steps
runtimes/vslib/asset precedence) and the MSBuild.targets/.propsfiles shipped in the SqlClient package. Specifically, investigate whether the package needs a<RuntimeList>or explicit<PackagePath>overrides so the SDK prefers the runtime-specific assembly during RID-targeted publish. Review howruntimes/unix/lib/net9.0/andlib/net9.0/are declared inMicrosoft.Data.SqlClient.nuspecand verify whether the.targetsfile should inject aCopyLocalLockFileAssemblies-style hint or an explicit asset copy step.net10.0-targeted TFM to the package (rather than relying onnet9.0fallback) would fully resolve the issue, or whether the asset selection bug exists independently.cheenamalhotra commentedon Jul 21, 2026
HI @mahdiyar021
There was no past regression, please read the linked issue for more details. The behavior is govered by Dotnet SDK as also mentioned in the other issue. Removing
-r linux-x64should solve the issue.mahdiyar021 commentedon Jul 21, 2026
i know removing -r linux-x64 will solve the issue , but dont wanna publish this way
cheenamalhotra commentedon Aug 13, 2026
@mahdiyar021 please open issue for dotnet/runtime repo - as we don't control runtime identifiers and binary resolutions. This is Dotnet SDK issue.
The recommended solutions should work and should be used until then.