我有一个针对.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发布项目时,一切都按预期工作。
答案 0 :(得分:1)
这是使用64位MSBuild版本(构建服务器,命令行)构建时的工具的已知错误。有关详细信息,请参阅this GitHub issue。
由于此问题已得到解决,您需要升级到Visual Studio / MSBuild的recently released 15.3.* versions以及可能还有2.0.0版本的.NET Core SDK。