.net-core - 发布自包含控制台应用程序失败

标签 .net-core

我安装了.NET SDK 2.1.301-win-x64.exe,然后将所有nuget软件包更新为2.1.1

在我的WebApp中,我有Nuget包Microsoft.AspNetCore.All 2.1.1Microsft.NETCore.App 2.1.0。在Nuget窗口中,我看到也有版本2.1.1,但是我无法选择它(受项目限制)

我的控制台应用程序中的同一个故事:Microsft.NETCore.App 2.1.0
我的第一个问题:这里已经出问题了吗?还是这是预期的行为?

如果我将WebApp构建为自包含的应用程序,则效果很好。

如果我将控制台应用程序称为自包含应用程序(自包含/win-x64)。我收到以下错误:

The project was restored using Microsoft.NETCore.App version 2.1.1, but with current settings, version 2.1.0 would be used instead. To resolve this issue, make sure the same settings are used for restore and for subsequent operations such as build or publish. Typically this issue can occur if the RuntimeIdentifier property is set during build or publish but not during restore."



此错误的来源是一个引用的项目。

我做错了什么?如果您需要其他信息,请告诉我,然后我会添加。

最佳答案

目前,这是一个已知问题。在您引用的项目的csproj文件中,设置TargetLatestRuntimePatch属性:

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

仅当.NET Core应用程序引用另一个.NET Core应用程序并且自包含的前滚仅在发布期间部分启动时,才会发生这种情况。

对于便携式应用程序,只需将Microsoft.NETCore.App 2.1.0版本作为目标即可,并且在目标计算机上运行时,将自动使用该计算机上可用的最新补丁程序。在最近的工具中,进行了更改,以便该工具将使用最新的已知修补程序版本来包含独立的应用程序,以便您将最新的修补程序版本自动捆绑到应用程序中。但是,这不会遍历项目间引用。

有关更多信息,请参见Self-contained deployment runtime roll forward

关于.net-core - 发布自包含控制台应用程序失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51086655/

相关文章:

visual-studio - 如何在 Visual Studio 2017 中为 .Net core 2.1 应用程序引用 F# 交互中的 Dll?

testing - 如何直接从命令行将 TestRunParameters 传递给 "dotnet test"命令

c# - 如何使用我的 nuget 包同时支持 .Net 6 和 .Net Framework 4.7.2

c# - 尝试在 EF Core 中使用 `ThenInclude` 时出现异常

.net-core - Net Core Worker Windows服务中的EF Core DBContext

asp.net-core - .NETCore PasswordHasher.HashPassword 不使用 TUser user ,但为什么包含在方法签名中?

c# - .NET Core NuGet EF Core 版本不匹配

c# - .net Core 中所有 HttpClient 实例的默认配置

c# - 如何将事件监听器添加到通过依赖项注入(inject)实例化的对象?

c# - 如何使用 JSONConvert 将变量 Result 转换为对象?