.NETcore, UWP - can't install NuGet package

2019-07-30 19:53发布

问题:

I try to create project using Universal Windows Platform. I did a few of them but after download .NET Core i have problem with NuGet Packages. When i try to Install MySql.Data i get

Package restore failed.

Output:

MySql.Data 6.9.9 is not compatible with UAP,Version=v10.0.
Some packages are not compatible with UAP,Version=v10.0.
MySql.Data 6.9.9 is not compatible with UAP,Version=v10.0 (win10-arm).
Some packages are not compatible with UAP,Version=v10.0 (win10-arm).
MySql.Data 6.9.9 is not compatible with UAP,Version=v10.0 (win10-arm-aot).
Some packages are not compatible with UAP,Version=v10.0 (win10-arm-aot).
MySql.Data 6.9.9 is not compatible with UAP,Version=v10.0 (win10-x64).
Some packages are not compatible with UAP,Version=v10.0 (win10-x64).
MySql.Data 6.9.9 is not compatible with UAP,Version=v10.0 (win10-x64-aot).
Some packages are not compatible with UAP,Version=v10.0 (win10-x64-aot).
MySql.Data 6.9.9 is not compatible with UAP,Version=v10.0 (win10-x86).
Some packages are not compatible with UAP,Version=v10.0 (win10-x86).
MySql.Data 6.9.9 is not compatible with UAP,Version=v10.0 (win10-x86-aot)

I read I should update .NET core to version 5.2.2 but it didn't work. I have no idea what should i do. I have also problem with BouncyCastle package but i found Portable-BouncyCastle version.

Here is my project.json

{
  "dependencies": {
    "Microsoft.NETCore.UniversalWindowsPlatform": "5.2.2",
    "Portable.BouncyCastle-Signed": "1.7.0.2"
  },
  "frameworks": {
    "uap10.0": {}
  },
  "runtimes": {
    "win10-arm": {},
    "win10-arm-aot": {},
    "win10-x86": {},
    "win10-x86-aot": {},
    "win10-x64": {},
    "win10-x64-aot": {}
  }
}

回答1:

The problem is caused by the fact that MySql.Data is not compatible with UWP. When you see the Package Manager output, this is stated clearly:

Package MySql.Data 6.9.9 is not compatible with uap10.0 (UAP,Version=v10.0).
Package MySql.Data 6.9.9 supports:
  - net40 (.NETFramework,Version=v4.0)
  - net45 (.NETFramework,Version=v4.5)

I have found a repo on GitHub, that is apparently trying to take the compatible APIs from the MySql.Data package so that the app can pass Windows Store certification, but I have not tried it.

It seems however, that it was possible to install older versions of MySql.Data (6.9.7) into a UWP project, although it was not possible to publish the app to Store later - see the example here.

The problem with BouncyCastle is very analogous, the portable version is compatible with UWP.