VSTS 和 WIX 上的 MSBuildExtensionsPath

标签 msbuild wix azure-devops

我有一个 Visual Studio 解决方案,我们一直在使用 Visual Studio Online Build 使用 VS 2015 构建它。我们想将构建转换为 VS 2017。它在本地为我构建,没有错误。但是,当使用“VS2017 托管”构建代理在线构建时,在尝试构建基于 WIX 的 MSI 时失败并出现以下错误:

DEV\Setup\UISetup\UISetup.wixproj(56,3): Error MSB4019: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\WiX\v3.x\Wix.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

故障排除,wixproj 确实有此路径的导入语句:

$(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets

我在构建中添加了一些额外的步骤,发现以下是两个构建代理的比较:

“托管”(在此 VS 2015 构建代理上构建)

 wix.targets Is Here:     C:\Program Files (x86)\MSBuild\Microsoft\WiX\v3.x\wix.targets 

 With Diagnostic output on MSBuild, here are the MSBuild property settings
 2017-08-19T19:12:13.3864207Z MSBuildExtensionsPath   = C:\Program Files (x86)\MSBuild
 2017-08-19T19:12:13.3864207Z MSBuildExtensionsPath32 = C:\Program Files (x86)\MSBuild
 2017-08-19T19:12:13.3864207Z MSBuildExtensionsPath64 = C:\Program Files\MSBuild

托管 VS2017(同一构建在此构建代理上失败)

 Looking here for wix.targets:     C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\WiX\v3.x\Wix.targets <-- which errors

 But wix.targets is here:          C:\Program Files (x86)\MSBuild\Microsoft\WiX\v3.x\wix.targets <-- same as “Hosted” build agent

 With Diagnostic output on MSBuild, here are the MSBuild property settings
 2017-08-19T19:21:06.5320962Z MSBuildExtensionsPath   = C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild <-- Different on this build agent
 2017-08-19T19:21:06.5320962Z MSBuildExtensionsPath32 = C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild <-- Different on this build agent
 2017-08-19T19:21:06.5320962Z MSBuildExtensionsPath64 = C:\Program Files\MSBuild

我已经向 Microsoft 支持开具了工单,但到目前为止,他们没有任何帮助。真正的问题是 MSBuildExtensionsPath32 指向“VS2017 Hosted”构建代理上的另一个文件夹,但 wix.targets 文件位于原始文件夹中。我不想硬编码到 wix.targets 的路径,但我真的没有看到替代方案。

有什么想法吗?

谢谢。

最佳答案

VS 2017 现在使用独立安装,其中多个版本的 VS(例如 VS 2017 社区版、企业版和 VS 2017 预览版)可以并排安装,不再是机器范围的安装。

这意味着所有扩展都需要安装到 VS 版本本身,就像 WiX 的 VS 2017 插件一样。这意味着当使用 VS 2017 安装的 msbuild 工具构建时,如果扩展没有安装到特定的 VS 实例中,它可能找不到全局安装的工具,如 WiX,这似乎是托管 VSTS 代理的情况。

为了解决此类问题,NuGet 打包了 like this one (维护于 https://github.com/kzu/WiX )包含构建 WiX 项目所需的工具,因此 nuget 恢复将获取所需的 Assets ,项目将在构建期间使用这些 Assets ,而不需要在构建代理上安装软件。

关于VSTS 和 WIX 上的 MSBuildExtensionsPath,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45862218/

相关文章:

tfs - 如何从VS2010用msbuild运行nunit

visual-studio - msbuild 自定义任务

azure - 如何在 VSTS 构建中将 Webpack 项目输出与 Asp.Net 项目输出结合起来?

git - 根据对子文件夹的更改触发 Azure DevOps 构建

asp.net-mvc - 基于条件编译符号启用 MVCBuildViews

c# - MSBUILD 引发错误 : The SDK 'Microsoft.NET.Sdk' specified could not be found

wix - 如何在 WiX 中为 Windows Installer 属性获取文件夹的短名称?

xslt - 如何为 heat.exe 收集的文件创建快捷方式?

wix - 如何配置 .wxs 文件以在写入 FEATURE_BROWSER_EMULATION RegistryKey 时检测最新版本的 IE?

tfs - 字段 'State' 包含不在支持值列表中的值 'Approved'