由于 MSB4019,travis 构建失败 运行 msbuild

travis build fails running msbuild due to MSB4019

我正在尝试使用 travis 在 windows 环境中自动构建一个 golang 项目,并使用 msbuildwix 打包 .exe

完全相同的配置适用于 Github 操作,因此我相信 .wixprojwxs 都是正确的,并且 [=14] 的配置存在一些问题=] 在 travis 安装中,但我没有更多的线索。

可能是 travis 安装的 msbuild 不包含所需的 wix 工具集,我尝试安装它们,但是在创建包时错误仍然存​​在


错误

C:\Users\travis\gopath\src\github.com\gallo-cedrone\nri-elasticsearch\pkg\windows\nri-amd64-installer\nri-installer.wixproj" (default target) (1) ->
C:\Users\travis\gopath\src\github.com\gallo-cedrone\nri-elasticsearch\pkg\windows\nri-amd64-installer\nri-installer.wixproj(34,5): 
error MSB4019: The imported project "C:\Program Files (x86)\Microsoft Visual Studio17\BuildTools\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.

.特拉维斯

...
  - os: windows
    env:
    - MSBUILD_PATH="c:\Program Files (x86)\Microsoft Visual Studio17\BuildTools\MSBuild.0\Bin"
    before_script:
    - powershell Install-WindowsFeature Net-Framework-Core
    - cinst -y wixtoolset
    script:
    - export PATH=$MSBUILD_PATH:$PATH
    - go test ./src/
    - go build -v -o ./target/bin/windows_amd64/nri-elasticsearch.exe  ./src/
    - msbuild.exe -version
    - cd ./pkg/windows/nri-amd64-installer/ ; pwd ; env ; msbuild.exe ./nri-installer.wixproj
...

travis job logs

感谢enter link description here

,我找到了解决方案

基本上我是在安装wixtools,但是安装文件夹不是vs2017预期的文件夹。

只需更改以下内容即可解决此问题: <Import Project="$(WixTargetsPath)" />

与:

<Import Project="$(WixTargetsPath)" Condition=" '$(WixTargetsPath)' != '' " />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets" Condition=" '$(WixTargetsPath)' == '' AND Exists('$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets') " />

并删除 WixTargetsPath 关闭条件。