TransformXml 任务在 linux 上使用单声道通过 msbuild 失败

TransformXml task fails via msbuild on linux using mono

按照 this answer 中的步骤操作后,尝试通过 mono(使用 msbuild)构建项目时,出现以下错误:

(AfterCompile target) -> project.csproj(469,5): error MSB4062: The "TransformXml" task could not be loaded from the assembly /usr/lib/mono/xbuild/Microsoft/VisualStudio/v15.0/Web/Microsoft.Web.Publishing.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.

好像Microsoft.Web.Publishing.Tasks.dll不可用。

在 linux 上通过单声道,此文件不存在。要解决此问题,请按照下列步骤操作:

  1. 安装 nuget 包MSBuild.Microsoft.VisualStudio.Web.targets
  2. 右键单击您的项目,然后单击 "Unload Project"
  3. 右键单击您的(现已卸载的)项目,然后单击 "Edit MyProjectName.csproj"
  4. 替换此行:
<UsingTask TaskName="TransformXml" AssemblyFile="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Web\Microsoft.Web.Publishing.Tasks.dll" />

使用更新后的 nuget Microsoft.Web.Publishing.Tasks.dll 位置(根据需要更新 MSBuild.Microsoft.VisualStudio.Web.targets.14.0.0.3 中的版本名称):

<UsingTask TaskName="TransformXml" AssemblyFile="..\packages\MSBuild.Microsoft.VisualStudio.Web.targets.14.0.0.3\tools\VSToolsPath\Web\Microsoft.Web.Publishing.Tasks.dll" />
  1. 重新加载您的项目,瞧,在 linux 上构建工作!