无法发布 ASP.NET 无法加载具有 "CreateManifestFile" 任务的核心应用程序

Unable to publish ASP.NET Core application with "CreateManifestFile" task could not be loaded

我有一个 ASP.NET 核心应用程序,我可以通过 Visual Studio 2017 使用网络部署和预配置的发布配置文件发布它。现在我需要配置 CI 并尝试实现与命令行相同,所以我安装了 [.NET Core SDK][1] 并遵循了 this guide

dotnet build -c release /p:DeployOnBuild=true /p:PublishProfile=publish-profile-name

不幸的是,它给出了以下错误:

C:\Program Files\dotnet\sdk.0.4\Sdks\Microsoft.NET.Sdk.Publish\build\netstanda rd1.0\PublishTargets\Microsoft.NET.Sdk.Publish.MSDeploy.targets(227,5): error MSB4062: The "CreateManifestFile" task could not be loaded from the assembly C:\Program Files\dotnet\sdk.0.4\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0 ....\tools\netcoreapp1.0\Microsoft.NETCore.Sdk.Publish.Tasks.dll. Confirm that the declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.

如何修复 dotnet build 行?

如果您的发布配置文件使用 MSDeploy,则无法通过基于 .NET Core 的构建工具构建它 (dotnet build)。

查看相关的 GitHub 问题 https://github.com/aspnet/websdk/issues/166

解决方法是使用 VS 2017 安装中的 msbuild /p:Configuration=Release … 而不是 dotnet build