【问题标题】:MSBuild error when specifying PublishProfile for ASP.NET.Core project为 ASP.NET.Core 项目指定 PublishProfile 时出现 MSBuild 错误
【发布时间】:2017-08-15 17:26:39
【问题描述】:

我有一个面向 .NET Framework 4.6.2 的 ASP.NET Core 1.1.2 项目。我最近安装了最新版本的 Visual Studio (15.2 26430.16),现在无法使用 MSBuild 版本 15.1.1012.6693 构建项目。使用 PublishProfile 时发生错误。

MSBuild 命令是:

msbuild D:\project\project.csproj /p:DeployOnBuild=true /p:PublishProfile=dist

错误是:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\TransformTargets\Microsoft.NET.Sdk.Publish.TransformFiles.targets(54,5): error MSB4062: The "TransformWebConfig" task could not be loaded from the assembly C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\..\..\tools\net46\\Microsoft.NET.Sdk.Publish.Tasks.dll. Could not load file or assembly 'file:///C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.NET.Sdk.Publish\tools\net46\Microsoft.NET.Sdk.Publish.Tasks.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format. Confirm that the <UsingTask> 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. [D:\project\project.csproj]

它在不指定发布配置文件时有效。但是,从 Visual Studio 发布项目时,一切正常。

【问题讨论】:

    标签: asp.net-core msbuild .net-standard


    【解决方案1】:

    这是使用 64 位 MSBuild 版本(构建服务器、命令行)构建时工具的已知错误。详情请见this GitHub issue

    由于此问题已得到修复,您需要升级到 Visual Studio / MSBuild 的recently released 15.3.* versions,可能还需要升级到 .NET Core SDK 的 2.0.0 版本。

    【讨论】:

    • 非常感谢。升级 SDK 就够了。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-04-16
    • 2018-05-28
    • 1970-01-01
    • 1970-01-01
    • 2013-06-03
    • 1970-01-01
    • 2017-10-25
    相关资源
    最近更新 更多