c# - 该项目使用 Microsoft.NETCore.App 版本 2.1.0 恢复,但使用当前设置,将使用版本 2.1.0-rtm-26515-03

标签 c# asp.net-core visual-studio-2017 nuget

目前我有一个用 c# 和 web api 和 net core 2.0 制作的微服务

在 nutget 包中,我已经找到了 2.1 版的 net core,我决定安装它,以更新我的应用程序。我改变了目标,如下所示

enter image description here

但是当我尝试编译它时会产生这个错误

enter image description here

该项目是使用 Microsoft.NETCore.App 版本 2.1.0 恢复的,但在当前设置下,将改用版本 2.1.0-rtm-26515-03。要解决此问题,请确保将相同的设置用于还原和后续操作(例如构建或发布)。通常,如果在生成或发布期间设置了 RuntimeIdentifier 属性但未在还原期间设置,则可能会发生此问题。

我的依赖仍然是这样

enter image description here

最佳答案

The project was restored using Microsoft.NETCore.App version 2.1.0, but with current settings, version 2.1.0-rtm-26515-03 would be used instead

这是一个 known issue此时此刻。要解决此问题,您可以尝试以下解决方法:

  • .csproj 文件中添加TargetLatestRuntimePatch 属性:

    <PropertyGroup>
      <TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
    </PropertyGroup>
    

或者

  • .csproj中设置RuntimeFrameworkVersionRuntimeIdentifier 文件:

     <PropertyGroup>
       <RuntimeFrameworkVersion>2.1.1</RuntimeFrameworkVersion>
       <PlatformTarget>AnyCPU</PlatformTarget>
       <RuntimeIdentifier>win-x64</RuntimeIdentifier>
     </PropertyGroup>
    

如果上述解决方法对您不起作用,请查看 investigation issue 上的更多解决方法.

参见 Self-contained deployment runtime roll forward获取更多信息。

关于c# - 该项目使用 Microsoft.NETCore.App 版本 2.1.0 恢复,但使用当前设置,将使用版本 2.1.0-rtm-26515-03,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51642172/

相关文章:

c# - 从 Visual Studio 2017 RC 降级到 Visual Studio 2015 的解决方案

c# - AutoFilterRow 上的 XtraGridView 自定义过滤器

c# - 在 Unity C# 中禁用附加到游戏对象的脚本

c# - 更新失败 - Entity Framework Core

c# - Visual Studio 2017 不会加载 .NET Standard 库中的 .NET Framework 引用

asp.net - VS2017无法识别我在m机器上安装了.NET Core 2.0 Preview 1

c# - 显式地将基类转换为派生类

c# - 类型转换盒装值

mysql - 如何将我在bluemix中的asp.net core连接到Mysql迁移数据库

asp.net-core - 新的 ASP.NET 5 预览项目无法运行