【发布时间】:2020-03-10 12:27:35
【问题描述】:
我在运行用于转换我的配置文件的 gulp 任务时遇到问题。它报告以下错误:
error MSB4062: The "TransformXml" task could not be loaded from the assembly C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VisualStudio\v16.0\Web\Microsof t.Web.Publishing.Tasks.dll. Could not load file or assembly 'Microsoft.Build.Utilities.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. Confi rm 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.
任务的作用:
- 它创建一个
_msbuild.proj文件,其中包含要转换的配置文件。文件长这样(显然 Source、Transform 和 Destination 都是用真实数据填充的):
<Project ToolsVersion="4.0" DefaultTargets="Demo" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="TransformXml" AssemblyFile="C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VisualStudio\v16.0\Web\Microsoft.Web.Publishing.Tasks.dll"/>
<Target Name="Transform">
<TransformXml Source="" Transform="" Destination=""/>
</Target>
</Project>
- 它针对 msbuild 运行此文件:
C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319\\msbuild.exe .\_msbuild.proj /t:Transform
我已经看过this answer which suggests it is a nuget package and might be corrupted。我认为情况并非如此,因为我项目中的其他人都没有这个问题。我也确实有问题的 dll - Microsoft.Build.Utilities.Core 但是在不同的地方安装了更高版本(16.4.0)以及 dotnet 和 VS 安装。
我看到的唯一区别是我使用的是 VS 2019,并且在磁盘上的位置与在 gulp 转换模块中的不同位置有 Microsoft.Web.Publishing.Tasks.dll(一个包含 TransformXml 任务并依赖于缺失库的库) - 我有它在 C:\Program Files (x86)\Microsoft Visual Studio 中,而其他人在 C:\Program Files (x86)\MSBuild 中拥有它
我在这个问题上卡了将近一天,动弹不得。
【问题讨论】:
标签: .net visual-studio msbuild