使用'.NETFramework,Version = v4.6.1'而不是项目目标框架'恢复 [英] was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '

查看:237
本文介绍了使用'.NETFramework,Version = v4.6.1'而不是项目目标框架'恢复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试引用一个明确为 .NetStandard2.0 的nuget程序包.我们拥有此程序包的源代码,并将其编写为目标.netstandard.我们确实有一个CI管道,因此当我们推送此代码时,它将构建并释放nuget包.当我尝试将生成的nuget包引用到当前的.netCore应用程序中时,出现以下错误:

I am trying to reference a nuget package which is clearly .NetStandard2.0. We own the source code for this package and written it to target .netstandard. We do have a CI pipeline so that when we push this code, it builds and releases the nuget package. When I try to reference the resulting nuget package into my current .netCore application, i get following error:

是使用'.NETFramework,Version = v4.6.1'而不是项目目标框架'.NETCoreApp,Version = v2.1'恢复的.该软件包可能与您的项目不完全兼容.

这对我来说没有任何意义.到目前为止,我已经尝试了以下调试步骤:

That does not make any sense to me. So far I have tried following debugging steps:

  • 直接将源代码引用为对我的项目的项目引用.哪个工作正常.
  • dotpeek 中分析生成的nuget程序包,以确保它实际上是.netstandard程序包.
  • 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.

不确定是什么使它认为它随时都在瞄准.下面是我的.csproj配置的样子

Not sure what makes it think that it was targeting at any point. below is how my .csproj configuration looks like

< 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?

推荐答案

我遇到了一个类似的问题:我通过Azure Artifacts发布了自己的NetStandard2.0程序包,然后尝试在netcore应用程序中使用它.

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.

事实证明,问题在于我将我的程序包命名为与现有NuGet程序包相同的名称.我的Azure Artifacts nuget提要在Visual Studio中已正确配置,但是当它尝试安装包时,它会首先尝试默认的NuGet提要,然后选择另一个(恰好是NetFramework)而不是我的.

It turned out that the problem was that I had named my package the same as an existing NuGet package. 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.

一旦我将包重命名为唯一的包(我刚刚添加了自己的名称空间)并重新发布,所有包都可以正常工作.

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.

这篇关于使用'.NETFramework,Version = v4.6.1'而不是项目目标框架'恢复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆