无法将 MySQL 数据 Nuget 包添加到 ASP 核心项目
Unable to add MySQL Data Nuget package to ASP Core Project
我正在尝试将 MySQL Data Nuget 包添加到我的 ASP Web Core 项目中,但出现此错误:
One or more packages are incompatible with .NETCoreApp,Version=v1.1 (win-x86).
我正在为 Mac 使用 Visual Studio。这是我得到的完整错误日志:
Running non-parallel restore.
Reading project file /Users/dk/Documents/HM/Backend/HMBackend/HMBackend/HMBackend.csproj.
Restoring packages for /Users/dk/Documents/HM/Backend/HMBackend/HMBackend/HMBackend.csproj...
Restoring packages for .NETCoreApp,Version=v1.1...
Resolving conflicts for .NETCoreApp,Version=v1.1...
Scanning packages for runtime.json files...
Merging in runtimes defined in package/Microsoft.NETCore.DotNetHostPolicy 1.1.0.
Merging in runtimes defined in package/Microsoft.NETCore.Runtime.CoreCLR 1.1.1.
Merging in runtimes defined in package/Microsoft.NETCore.Platforms 1.1.0.
Merging in runtimes defined in package/Microsoft.NETCore.DotNetHostResolver 1.1.0.
Merging in runtimes defined in package/Microsoft.NETCore.Jit 1.1.1.
Merging in runtimes defined in package/Microsoft.NETCore.Windows.ApiSets 1.0.1.
Merging in runtimes defined in package/Microsoft.NETCore.Targets 1.1.0.
Merging in runtimes defined in package/Microsoft.NETCore.DotNetHost 1.1.0.
Restoring packages for .NETCoreApp,Version=v1.1 (win)...
Resolving conflicts for .NETCoreApp,Version=v1.1 (win)...
Restoring packages for .NETCoreApp,Version=v1.1 (win-x64)...
Resolving conflicts for .NETCoreApp,Version=v1.1 (win-x64)...
Restoring packages for .NETCoreApp,Version=v1.1 (win-x86)...
Resolving conflicts for .NETCoreApp,Version=v1.1 (win-x86)...
Checking compatibility of packages on .NETCoreApp,Version=v1.1.
Checking compatibility for HMBackend 1.0.0 with .NETCoreApp,Version=v1.1.
Checking compatibility for MySql.Data 6.9.9 with .NETCoreApp,Version=v1.1.
Package MySql.Data 6.9.9 is not compatible with netcoreapp1.1 (.NETCoreApp,Version=v1.1). Package MySql.Data 6.9.9 supports:
- net40 (.NETFramework,Version=v4.0)
- net45 (.NETFramework,Version=v4.5)
Checking compatibility for System.Diagnostics.FileVersionInfo 4.0.0 with .NETCoreApp,Version=v1.1 (win-x86).
Checking compatibility for System.Xml.XPath.XDocument 4.0.1 with .NETCoreApp,Version=v1.1 (win-x86).
Checking compatibility for runtime.any.System.Reflection.Extensions 4.3.0 with .NETCoreApp,Version=v1.1 (win-x86).
Checking compatibility for runtime.any.System.Reflection.Primitives 4.3.0 with .NETCoreApp,Version=v1.1 (win-x86).
Checking compatibility for Microsoft.NETCore.DotNetHost 1.1.0 with .NETCoreApp,Version=v1.1 (win-x86).
Checking compatibility for runtime.win.System.Console 4.3.0 with .NETCoreApp,Version=v1.1 (win-x86).
Checking compatibility for runtime.any.System.Diagnostics.Tools 4.3.0 with .NETCoreApp,Version=v1.1 (win-x86).
Checking compatibility for Microsoft.AspNetCore.Cryptography.Internal 1.1.2 with .NETCoreApp,Version=v1.1 (win-x86).
Checking compatibility for Microsoft.AspNetCore.DataProtection.Abstractions 1.1.2 with .NETCoreApp,Version=v1.1 (win-x86).
One or more packages are incompatible with .NETCoreApp,Version=v1.1 (win-x86).
Incompatible packages: 1
Package restore failed. Rolling back package changes for 'HMBackend'.
这是我的 .csproj 的样子:
<?xml version="1.0" encoding="UTF-8"?>
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Folder Include="wwwroot\" />
<Folder Include="DAO\" />
<Folder Include="Model\" />
<Folder Include="Helpers\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.3" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.2" />
<PackageReference Include="System.Data.SqlClient" Version="4.3.1" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
<PackageReference Include="System.Net.Http" Version="4.3.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="1.2.0" />
</ItemGroup>
<ItemGroup>
<Compile Remove="Model\ResponseCallBack.cs" />
</ItemGroup>
</Project>
我该如何解决这个错误?
来自 NuGet 输出:
Package MySql.Data 6.9.9 is not compatible with netcoreapp1.1 (.NETCoreApp,Version=v1.1). Package MySql.Data 6.9.9 supports:
- net40 (.NETFramework,Version=v4.0)
- net45 (.NETFramework,Version=v4.5)
MySql.Data NuGet 包包含 .NET 4.0 和 4.5 的程序集。您不能在 .NET Core 1.1 项目中使用它们。
选项:
- 查找另一个 MySql 支持 .NET Standard、PCL 或 .NET Core 的 NuGet 包或库。例如MySqlConnector。
- 将您的项目更改为面向 .NET Core 2.0。
- MySql.Data NuGet 包需要测试以查看它是否与 .NET Core 2.0 兼容。虽然您可以使用 .NET Core 2.0 项目中以 .NET 为目标的 NuGet 包,但不能保证程序集能够正常工作,因为它可能使用了一些 .NET Core 2.0 不支持的 API。
我正在尝试将 MySQL Data Nuget 包添加到我的 ASP Web Core 项目中,但出现此错误:
One or more packages are incompatible with .NETCoreApp,Version=v1.1 (win-x86).
我正在为 Mac 使用 Visual Studio。这是我得到的完整错误日志:
Running non-parallel restore.
Reading project file /Users/dk/Documents/HM/Backend/HMBackend/HMBackend/HMBackend.csproj.
Restoring packages for /Users/dk/Documents/HM/Backend/HMBackend/HMBackend/HMBackend.csproj...
Restoring packages for .NETCoreApp,Version=v1.1...
Resolving conflicts for .NETCoreApp,Version=v1.1...
Scanning packages for runtime.json files...
Merging in runtimes defined in package/Microsoft.NETCore.DotNetHostPolicy 1.1.0.
Merging in runtimes defined in package/Microsoft.NETCore.Runtime.CoreCLR 1.1.1.
Merging in runtimes defined in package/Microsoft.NETCore.Platforms 1.1.0.
Merging in runtimes defined in package/Microsoft.NETCore.DotNetHostResolver 1.1.0.
Merging in runtimes defined in package/Microsoft.NETCore.Jit 1.1.1.
Merging in runtimes defined in package/Microsoft.NETCore.Windows.ApiSets 1.0.1.
Merging in runtimes defined in package/Microsoft.NETCore.Targets 1.1.0.
Merging in runtimes defined in package/Microsoft.NETCore.DotNetHost 1.1.0.
Restoring packages for .NETCoreApp,Version=v1.1 (win)...
Resolving conflicts for .NETCoreApp,Version=v1.1 (win)...
Restoring packages for .NETCoreApp,Version=v1.1 (win-x64)...
Resolving conflicts for .NETCoreApp,Version=v1.1 (win-x64)...
Restoring packages for .NETCoreApp,Version=v1.1 (win-x86)...
Resolving conflicts for .NETCoreApp,Version=v1.1 (win-x86)...
Checking compatibility of packages on .NETCoreApp,Version=v1.1.
Checking compatibility for HMBackend 1.0.0 with .NETCoreApp,Version=v1.1.
Checking compatibility for MySql.Data 6.9.9 with .NETCoreApp,Version=v1.1.
Package MySql.Data 6.9.9 is not compatible with netcoreapp1.1 (.NETCoreApp,Version=v1.1). Package MySql.Data 6.9.9 supports:
- net40 (.NETFramework,Version=v4.0)
- net45 (.NETFramework,Version=v4.5)
Checking compatibility for System.Diagnostics.FileVersionInfo 4.0.0 with .NETCoreApp,Version=v1.1 (win-x86).
Checking compatibility for System.Xml.XPath.XDocument 4.0.1 with .NETCoreApp,Version=v1.1 (win-x86).
Checking compatibility for runtime.any.System.Reflection.Extensions 4.3.0 with .NETCoreApp,Version=v1.1 (win-x86).
Checking compatibility for runtime.any.System.Reflection.Primitives 4.3.0 with .NETCoreApp,Version=v1.1 (win-x86).
Checking compatibility for Microsoft.NETCore.DotNetHost 1.1.0 with .NETCoreApp,Version=v1.1 (win-x86).
Checking compatibility for runtime.win.System.Console 4.3.0 with .NETCoreApp,Version=v1.1 (win-x86).
Checking compatibility for runtime.any.System.Diagnostics.Tools 4.3.0 with .NETCoreApp,Version=v1.1 (win-x86).
Checking compatibility for Microsoft.AspNetCore.Cryptography.Internal 1.1.2 with .NETCoreApp,Version=v1.1 (win-x86).
Checking compatibility for Microsoft.AspNetCore.DataProtection.Abstractions 1.1.2 with .NETCoreApp,Version=v1.1 (win-x86).
One or more packages are incompatible with .NETCoreApp,Version=v1.1 (win-x86).
Incompatible packages: 1
Package restore failed. Rolling back package changes for 'HMBackend'.
这是我的 .csproj 的样子:
<?xml version="1.0" encoding="UTF-8"?>
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Folder Include="wwwroot\" />
<Folder Include="DAO\" />
<Folder Include="Model\" />
<Folder Include="Helpers\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.3" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.2" />
<PackageReference Include="System.Data.SqlClient" Version="4.3.1" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
<PackageReference Include="System.Net.Http" Version="4.3.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="1.2.0" />
</ItemGroup>
<ItemGroup>
<Compile Remove="Model\ResponseCallBack.cs" />
</ItemGroup>
</Project>
我该如何解决这个错误?
来自 NuGet 输出:
Package MySql.Data 6.9.9 is not compatible with netcoreapp1.1 (.NETCoreApp,Version=v1.1). Package MySql.Data 6.9.9 supports:
- net40 (.NETFramework,Version=v4.0)
- net45 (.NETFramework,Version=v4.5)
MySql.Data NuGet 包包含 .NET 4.0 和 4.5 的程序集。您不能在 .NET Core 1.1 项目中使用它们。
选项:
- 查找另一个 MySql 支持 .NET Standard、PCL 或 .NET Core 的 NuGet 包或库。例如MySqlConnector。
- 将您的项目更改为面向 .NET Core 2.0。
- MySql.Data NuGet 包需要测试以查看它是否与 .NET Core 2.0 兼容。虽然您可以使用 .NET Core 2.0 项目中以 .NET 为目标的 NuGet 包,但不能保证程序集能够正常工作,因为它可能使用了一些 .NET Core 2.0 不支持的 API。