Skip to content

dotnet publish -r win-x64 not publish right version of System.Data.SqlClient for netcoreapp3.0 and get PlatformNotSupportedException #29522

Closed

Description

@yyjdelete
dotnet --info
.NET Core SDK(反映任何 global.json):
 Version:   3.0.100-preview5-011568
 Commit:    b487ff10aa

运行时环境:
 OS Name:     Windows
 OS Version:  10.0.18895
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\3.0.100-preview5-011568\

Host (useful for support):
  Version: 3.0.0-preview5-27626-15
  Commit:  61f30f5a23

Step:

  1. Create two csproj
    Main:
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp3.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <ProjectReference Include="..\ClassLibrary1\ClassLibrary1.csproj" />
  </ItemGroup>
  
</Project>

ClassLibrary1:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="System.Data.SqlClient" Version="4.7.0-preview5.19224.8" />
  </ItemGroup>
</Project>

Main.cs

using System;
using System.Data.SqlClient;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            new SqlConnection();
            Console.WriteLine("Hello World!");
        }
    }
}
  1. dotnet publish -r win-x64
  2. Run the output file, and see PlatformNotSupportedException

Activity

  1. changed the title [-]`dotnet publish -r` not publish right version of `System.Data.SqlClient` for netcoreapp3.0 and get `System.PlatformNotSupportedException: System.Data.SqlClient is not supported on this platform.`[/-] [+]`dotnet publish -r win-x64` not publish right version of `System.Data.SqlClient` for `netcoreapp3.0` and get `PlatformNotSupportedException`[/+] on May 12, 2019
  2. karinazhou commented on May 15, 2019

    @karinazhou
    Member

    Hi @yyjdelete , thank you for reporting this. I will see whether I can reproduce this on my side.

  3. karinazhou commented on May 16, 2019

    @karinazhou
    Member

    @yyjdelete We are able to reproduce this issue locally by following your steps. After some investigation, the problem is due to the wrong System.Data.SqlClient.dll in the publish folder.

    The nuget package contains a bunch of System.Data.SqlClient.dlls for various platforms. When using dotnet publish on your application, it failed to find the correct dll for netcoreapp3.0 so it copied the general one which was in lib\netcoreapp2.1 as a result. The actual working System.Data.SqlClient.dll is in runtimes\win\lib\netcoreapp2.1 which should be picked up with the executable.

    We have tested netcoreapp2.1 and dotnet publish can work fine without PlatformNotSupportedException. However, since we haven't add netcoreapp3.0 yet and the System.Data.SqlClient nuget package uses strong-named assembly, dotnet publish is not able to work properly.

    One possible workaround for now is to manually copy the dll file from runtimes\win\lib\netcoreapp2.1 to the publish folder and this can eliminate the exception. Or you may need to wait for the support of netcoreapp3.0 in the future.

  4. lefig commented on May 19, 2019

    @lefig

    Hi @karinazhou,

    We happen to have the same problem too. It would be sure good to hear that the publish command does indeed get fixed in the next release.

    Best

  5. cheenamalhotra commented on Jul 15, 2019

    @cheenamalhotra
    Member

    Hi @yyjdelete @lefig

    Have you tried with .NET Core SDK Version: 3.0.100-preview6-012264.
    This issue seems to occur with older SDKs (preview5) but not with the newer one. Maybe it was fixed with some other changes in SDK.

    Please confirm so we will close the issue.

  6. yyjdelete commented on Jul 16, 2019

    @yyjdelete
    Author

    @cheenamalhotra
    Verified this is not happen with preview6 for me.
    Feel free to close it.

  7. transferred this issue fromdotnet/corefxon Feb 1, 2020
  8. added this to the 3.0 milestone on Feb 1, 2020
  9. ghost locked as resolved and limited conversation to collaborators on Dec 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions