发布自包含控制台应用程序失败 [英] Publishing a Self-contained Console app fails

查看:35
本文介绍了发布自包含控制台应用程序失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I installed the .NET SDK 2.1.301-win-x64.exe and afterwards updated all the nuget packages to 2.1.1.

在我的 WebApp 中,我有 Nuget 包 Microsoft.AspNetCore.All 2.1.1Microsft.NETCore.App 2.1.0.在 Nuget 窗口中,我看到还有 2.1.1 版,但我无法选择它(被项目阻止)

In my WebApp I have the Nuget Package Microsoft.AspNetCore.All 2.1.1 and Microsft.NETCore.App 2.1.0. In the Nuget Window I see that there's also the Version 2.1.1, but I can't select it (Blocked by Project)

我的控制台应用程序中的相同故事:Microsft.NETCore.App 2.1.0

Same story in my Console App: Microsft.NETCore.App 2.1.0

我的第一个问题:这里有什么问题吗?或者这是预期的行为?

My first question: Is here already something wrong? Or is this expected behavior?

如果我将 WebApp 构建为自包含应用程序,那效果很好.

If I build the WebApp as self contained App, that works well.

如果我将控制台应用程序构建为自包含应用程序(自包含/win-x64).我得到以下错误:

If I biuld the Console App as self contained App (Self-contained / win-x64). I get the follwoing Error:

该项目是使用 Microsoft.NETCore.App 版本 2.1.1 恢复的,但在当前设置下,将使用 2.1.0 版.到解决此问题,请确保使用相同的设置进行还原并用于后续操作,例如构建或发布.通常如果在运行期间设置了 RuntimeIdentifier 属性,则可能会发生此问题构建或发布,但不在恢复期间."

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."

此错误的来源是引用的项目.

The source of this error is a referenced project.

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

What do I do wrong? Let me know if you need additional information, then I will add it.

推荐答案

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

This is a known issue for the moment. In your referenced project's csproj file, set the TargetLatestRuntimePatch property:

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

这仅在 .NET Core 应用程序引用另一个 .NET Core 应用程序并且自包含前滚仅在发布期间部分启动时发生.

This only happens when a .NET Core application references another .NET Core application and self-contained roll-forward only partially kicks in during publish.

对于可移植的应用程序,以Microsoft.NETCore.App 2.1.0 版本为目标就足够了,在目标机器上运行时,将自动使用机器上可用的最新补丁.在最近的工具中,进行了更改,以便该工具将最新的已知补丁版本用于自包含应用程序,以便您自动将最新的补丁版本与您的应用程序捆绑在一起.但是,这不会流经项目到项目的引用.

For portable applications, it is enough to target 2.1.0 version of Microsoft.NETCore.App and when run on a target machine, the latest patch available on the machine will be used automatically. In recent tooling, a change was made so that the tooling would use the latest known patch version for self-contained applications so you automatically bundle the latest patch release with your application. However, this doesn't flow over project-to-project references.

参见 自包含的部署运行时前滚 了解更多信息.

See Self-contained deployment runtime roll forward for more information.

这篇关于发布自包含控制台应用程序失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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