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

编程入门 行业动态 更新时间:2024-10-19 23:33:35
本文介绍了已使用 '.NETFramework,Version=v4.6.1' 而不是项目目标框架 ' 恢复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我试图引用一个明显是 .NetStandard2.0 的 nuget 包.我们拥有此包的源代码并将其写入目标 standard.我们确实有一个 CI 管道,因此当我们推送此代码时,它会构建和发布 nuget 包.当我尝试将生成的 nuget 包引用到我当前的 Core 应用程序中时,出现以下错误:

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 standard. 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 Core 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 包,以确保它实际上是一个 standard 包.
  • 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 standard 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

netstandard2.0

不确定这里是否有任何其他配置块重要,但如果您需要更多信息,请告诉我.有什么想法吗?

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' 而不是项目目标框架 ' 恢复

本文发布于:2023-11-08 07:19:12,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1568709.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:而不是   框架   目标   项目   NETFramework

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!