简体   繁体   English

已使用 '.NETFramework,Version=v4.6.1' 而不是项目目标框架 ' 恢复

[英]was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '

I am trying to reference a nuget package which is clearly .NetStandard2.0 .我正在尝试引用一个 nuget 包,它显然是.NetStandard2.0 We own the source code for this package and written it to target .netstandard.我们拥有此包的源代码并将其写入目标 .netstandard。 We do have a CI pipeline so that when we push this code, it builds and releases the nuget package.我们确实有一个 CI 管道,因此当我们推送此代码时,它会构建和发布 nuget 包。 When I try to reference the resulting nuget package into my current .netCore application, i get following error:当我尝试将生成的 nuget 包引用到我当前的 .netCore 应用程序中时,出现以下错误:

was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.1'. This package may not be fully compatible with your project.

That does not make any sense to me.这对我来说没有任何意义。 So far I have tried following debugging steps:到目前为止,我已经尝试了以下调试步骤:

  • Referenced the source code directly as a project reference to my project.直接引用源代码作为我项目的项目引用。 Which did work all fine.哪个工作得很好。
  • Analyzing resulting nuget package in dotpeek to make sure that it in fact is a .netstandard package and it is.dotpeek分析生成的 nuget 包,以确保它实际上是一个 .netstandard 包。

Not sure what makes it think that it was targeting at any point.不知道是什么让它认为它在任何时候都是针对的。 below is how my .csproj configuration looks like下面是我的 .csproj 配置的样子

<TargetFramework>netstandard2.0</TargetFramework>

Not sure if any other config block matters here but let me know if you need more info on this.不确定这里是否有任何其他配置块重要,但如果您需要更多信息,请告诉我。 Any ideas?有任何想法吗?

I ran in to a similar issue where I was publishing my own NetStandard2.0 package via Azure Artifacts and then attempting to consume it in a netcore application.我遇到了一个类似的问题,我通过 Azure Artifacts 发布我自己的 NetStandard2.0 包,然后尝试在 netcore 应用程序中使用它。

It turned out that the problem was that I had named my package the same as an existing NuGet package.结果发现问题在于我将我的包命名为与现有 NuGet 包相同的名称。 My Azure Artifacts nuget feed was configured correctly in Visual Studio, but when it attempts to install the package it tries the default NuGet feed first and picks up the other one (which happened to be NetFramework only) rather than mine.我的 Azure Artifacts nuget 提要在 Visual Studio 中正确配置,但是当它尝试安装包时,它首先尝试默认的 NuGet 提要,然后选择另一个(恰好是 NetFramework 提要)而不是我的。

Once I renamed my package to be unique (I just added my own namespace) and re-published it all worked properly.一旦我将我的包重命名为唯一的(我刚刚添加了我自己的命名空间)并重新发布,它一切正常。

I guess that might not be the issue for everyone but it was for me.我想这可能不是每个人的问题,但对我来说是。

You have to use every packages in your project compatible with .NETCoreApp,Version=v2.0.您必须使用项目中与 .NETCoreApp,Version=v2.0 兼容的每个包。

There should be some package name before "was" in your error message.在错误消息中的“was”之前应该有一些包名。 For ex:例如:

Package 'Microsoft.AspNet.WebApi.Client 5.2.2' was restored
Package 'EntityFramework 6.2.0' was restored 

I ran into this issue as well.我也遇到了这个问题。 In my case, when the DLL was packaged and placed in the lib/ folder, the import warning occurred.在我的例子中,当 DLL 被打包并放置在lib/文件夹中时,出现了导入警告。 It was solved by placing the packaged DLL in the lib/netstandard2.0 folder.通过将打包lib/netstandard2.0 DLL放在lib/netstandard2.0文件夹中解决了。

I had the same problem.我有同样的问题。 To fix this要解决这个问题

  1. Look in VS2019 under dependencies / Packages.在依赖项/包下查看 VS2019。
  2. Then look for the packages with the warning sign next to them.然后寻找旁边带有警告标志的包裹。
  3. Goto your windows profile directory and delete the corresponding folder under .nuget转到您的windows配置文件目录并删除.nuget下的相应文件夹
  4. Delete the reference under dependencies / Packages删除依赖项/包下的引用
  5. Add the Nuget package via Manage Nuget Packages for solution通过 Manage Nuget Packages 添加 Nuget 包以获取解决方案

暂无
暂无

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

相关问题 使用&#39;.NETFramework,Version = v4.6.1&#39;而不是项目目标框架&#39;.NETCoreApp,Version = v2.0&#39;恢复了软件包&#39;Faker.Net 1.0.3&#39; - Package 'Faker.Net 1.0.3' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.0' 警告NU1701:使用&#39;.NETFramework,V ersion = v4.6.1&#39;而不是项目目标框架恢复了软件包&#39;System.Linq.Queryable 4.0.1&#39; - warning NU1701: Package 'System.Linq.Queryable 4.0.1' was restored using '.NETFramework,V ersion=v4.6.1' instead of the project target framework 如何修复`您的项目未引用“.NETFramework,Version=v4.6.1”框架...` - How to fix `Your project does not reference ".NETFramework,Version=v4.6.1" framework...` 解决错误“Microsoft.NETCore.App 1.0.0不支持框架.NETFramework,Version = v4.6.1” - Solving error “Microsoft.NETCore.App 1.0.0 does not support framework .NETFramework,Version=v4.6.1” 如何解决/解决异常未找到框架“ .NETFramework,Version = v4.6.1”的参考程序集? - How should I fix/resolve exception The reference assemblies for framework “.NETFramework,Version=v4.6.1” were not found? Project X的目标是&#39;.NETStandard,Version = v1.6&#39;。 它不能被针对&#39;.NETFramework,Version = v4.6.1&#39;的项目引用 - Project X targets '.NETStandard,Version=v1.6'. It cannot be referenced by a project that targets '.NETFramework,Version=v4.6.1' .net Core 2.0 - 使用 .NetFramework 4.6.1 而不是目标框架 .netCore 2.0 来恢复包。 软件包可能不完全兼容 - .net Core 2.0 - Package was restored using .NetFramework 4.6.1 instead of target framework .netCore 2.0. The package may not be fully compatible 使用&#39;.NETFFramework,Version = v4.6.1&#39;恢复了软件包&#39;Microsoft.AspNet.WebApi.Core 5.2.7&#39; - Package 'Microsoft.AspNet.WebApi.Core 5.2.7' was restored using '.NETFFramework,Version=v4.6.1' 找不到Azure devops构建失败的NETFramework,Version = v4.6.1“ - Azure devops build failed NETFramework,Version=v4.6.1" were not found 带有 .net framework 4.6.1 的 Asp.net Core 2.0 - 找不到参考程序集 &#39;.NETFramework/v4.6.1/Microsoft.CSharp.dll - Asp.net Core 2.0 with .net framework 4.6.1 - Cannot find reference assembly '.NETFramework/v4.6.1/Microsoft.CSharp.dll
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM