简体   繁体   English

将Netstandard程序包安装到.NET Core

[英]Installing a netstandard package to .NET Core

The library Google.Apis on NuGet claims the following: NuGet上的Google.Apis库声明以下内容:

Supported Platforms: 支持平台:

  • .NET Framework 4.5+ .NET Framework 4.5+
  • NetStandard1.3, providing .NET Core support NetStandard1.3,提供.NET Core支持

However, the command dotnet add package Google.Apis tells me error: Package 'Google.Apis' is incompatible with 'all' frameworks in project '/home/pavel/[...]/api.csproj'. 但是,命令dotnet add package Google.Apis告诉我error: Package 'Google.Apis' is incompatible with 'all' frameworks in project '/home/pavel/[...]/api.csproj'. .

Here is the csproj file being used: 这是正在使用的csproj文件:

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

  <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <Folder Include="wwwroot\" />
    <Folder Include="Utils\" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.All" />
  </ItemGroup>
</Project>

How do I install the package? 如何安装套件?

As discussed in the comments to the question, this was caused due to a nuget.config file that removed all sources. 正如对该问题的评论中所讨论的,这是由于nuget.config文件删除了所有源引起的。 When I reproduced the scenario on my local machine, here's the full output: 当我在本地计算机上重现场景时,这是完整的输出:

  Writing /tmp/tmpd4dcSu.tmp
info : Adding PackageReference for package 'Google.Apis' into project '/home/zivkan/apiTest/apiTest.csproj'.
log  : Restoring packages for /home/zivkan/apiTest/apiTest.csproj...
error: Unable to resolve 'Google.Apis ' for '.NETCoreApp,Version=v2.1'.
error: Package 'Google.Apis' is incompatible with 'all' frameworks in project '/home/zivkan/apiTest/apiTest.csproj'.

The second error message, the one you reported in your question, is very misleading. 第二个错误消息,即您在问题中报告的错误消息,极具误导性。 However, the first error message "Unable to resolve" gives a good hint that NuGet is unable to find the package. 但是,第一个错误消息“无法解析”给出了一个很好的提示,即NuGet无法找到该程序包。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM