首页 > 解决方案 > asp.NET 核心发布 Trimmed 退出,错误代码为 -532462766

问题描述

我正在尝试通过命令行发布我的 asp.net-core 应用程序并使用“PublishedTrimmed”功能。

我都试过了

dotnet build -c Release './project.csproj' /p:DeployOnBuild=true /p:PublishProfile=FolderProfile

dotnet publish -c Release './project.csproj' -o "outputPath"

build 命令中使用的发布配置文件如下所示:

<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <WebPublishMethod>FileSystem</WebPublishMethod>
    <PublishProvider>FileSystem</PublishProvider>
    <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <SiteUrlToLaunchAfterPublish />
    <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
    <ExcludeApp_Data>True</ExcludeApp_Data>
    <ProjectGuid>1b763e24-74f7-453c-bf79-210861cd0fd7</ProjectGuid>
    <publishUrl>[redacted]</publishUrl>
    <DeleteExistingFiles>True</DeleteExistingFiles>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <RuntimeIdentifier>win10-x64</RuntimeIdentifier>
    <PublishSingleFile>False</PublishSingleFile>
    <PublishTrimmed>True</PublishTrimmed>
    <SelfContained>true</SelfContained>
  </PropertyGroup>
</Project>

为了使用发布命令,我将相关代码添加到 csproj 文件中,如下所示:

<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
    <RuntimeIdentifier>win10-x64</RuntimeIdentifier>
    <SelfContained>true</SelfContained>
    <IsTransformWebConfigDisabled>true</IsTransformWebConfigDisabled>
    <PublishSingleFile>True</PublishSingleFile>
    <PublishTrimmed>True</PublishTrimmed>
  </PropertyGroup>
</Project>

可悲的是,我所做的所有尝试都导致了同样的错误:

C:\Program Files\dotnet\sdk\3.1.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.ILLink.targets(83,5): error MSB6006: "dotnet.exe" has exited with error code -532462766。

如果我在 Visual Studio 2019 中使用内置发布按钮,也会发生这种情况

我目前只安装了 v.3.1.101 (x64) .net-core SDK,它在不使用“PublishTrimmed”时可以正确构建和发布

错误消息并没有真正帮助我,所以谁能告诉我为什么会发生这个错误以及如何解决这个问题?

谢谢!

标签: asp.net.netasp.net-corepublish

解决方案


推荐阅读