c# - 构建成功但发布失败——此版本的Microsoft.AspNetCore.All只兼容netcoreapp2.2目标框架

标签 c# visual-studio build msbuild publishing

我有一个具有以下属性的 Web API 项目

  • .Net 核心 2.2
  • Visual Studio 2017
  • 版本:15.7.4

项目 .csproj 显然有以下设置

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

在 Visual Studio 中构建成功,但是当我尝试发布项目时出现以下错误

This version of Microsoft.AspNetCore.All is only compatible with the netcoreapp2.2 target framework. Please target netcoreapp2.2 or choose a version of Microsoft.AspNetCore.All compatible with netcoreapp2.1.

我正在使用 Visual Studio 菜单选项进行发布。 我正在发布到 Azure 应用服务。发布到 文件系统 没有显示任何错误。

我有如下的nuget

enter image description here

可能是什么原因?

最佳答案

我刚刚找到了一个奇怪的解决方案!

我已经创建了新的 publish 配置文件,它非常有效!似乎在将项目属性从 .Net Core 2.1 更改为 .Net Core 2.2 之后,我们总是需要创建一个新的配置文件!

关于c# - 构建成功但发布失败——此版本的Microsoft.AspNetCore.All只兼容netcoreapp2.2目标框架,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54076957/

相关文章:

c# - 对 ITVF 的引用引发 "second operation started on this context before a previous operation completed"异常

c++ - 变量值的后缀#DEN 是什么意思

git - 从 Visual Studio 推送 Git 存储库时运行 ssh.exe 时出错

c++ - 在命名线程后附加调试器时, native C++ 线程名称不会显示在 visual studio 线程窗口中

build - 如何更改 Gradle 下载位置

android - 错误 :Execution failed for task ':android:transformClassesAndResourcesWithProguardForRelease'

visual-studio-2008 - 无法将文件 "obj\Debug\project.dll"复制到 "bin\project.dll"。访问路径 'bin\project.dll' 被拒绝

c# - 如何在 winform 中关闭所有打开的对话框的主窗体

c# - ASP.net MVC dateFormat 验证问题,客户端验证

c# - LINQ - 带元素计数的双重分组