【问题标题】:Is that possible to publish ASP.Net Core 3.1 web application as a Single File是否可以将 ASP.Net Core 3.1 Web 应用程序作为单个文件发布
【发布时间】:2020-01-30 15:39:49
【问题描述】:

我知道我们能够以self-containedsinglefile 的形式发布 .Net Core 3.x 控制台应用程序。但是是否可以将 Web 应用程序作为单个文件发布?

我尝试使用

<RuntimeIdentifier>win10-x64</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<PublishReadyToRun>true</PublishReadyToRun>
<PublishSingleFile>true</PublishSingleFile>

但发布后我收到了错误ANCM Application DLL Not Found。我的申请在.Net Core 3.1.1

我该怎么做?

【问题讨论】:

  • 您是否尝试过将 asp.net 发布为自包含部署,这会将所有运行时的依赖文件放入一个文件夹中。然后在这个文件夹中使用命令行运行dotnet publish -r win-x64 -c Release /p:PublishSingleFile=true
  • @Clint 正如我所提到的,我设置了&lt;SelfContained&gt;true&lt;/SelfContained&gt;。但是在命令行而不是 Visual Studio 2019 上发布它重要吗?
  • @Clint 我也这样做了,但仍然遇到同样的错误。
  • 要向@Clint 提出您的问题,正如在similar thread 上所讨论的那样,您应该只需要either &lt;PublishSingleFile /&gt; or @987654331 @;正如您所怀疑的那样,这些都是多余的。请注意,您不应该需要&lt;SelfContained /&gt; 元素,正如&lt;PublishSingleFile /&gt; 所暗示的那样——尽管我也不认为它会造成任何伤害。
  • 我还应该注意original design document for single file publishing 在这里可能是一个有用的参考。我提出这一点是因为对本文档的大多数引用都指向旧位置,因此如果您不知道在哪里查找,目前很难找到。

标签: c# visual-studio-2019 asp.net-core-3.0 asp.net-core-3.1


【解决方案1】:

你应该编辑你的 webconfig 看起来像

 <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
      </handlers>

而不是

 <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
      </handlers>

【讨论】:

    猜你喜欢
    • 2020-04-08
    • 2016-07-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-17
    • 2021-05-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多