问题描述
即使使用--no-build标志,在运行dotnet测试时如何避免Windows Installer Wix构建? 即使安装了Wix工具,它仍然会失败。
命令行
dotnet.exe test --configuration Release --no-build
.msi.wixproj: error : The WiX Toolset v3.11 (or newer) build tools must be installed to build this project.
解决方法
这是解决该问题的方法,请使用标志通过使用MSBuild保留关键字MSBuildRuntimeType跳过将WixTools导入到项目中。
您必须按如下所示修改.wixproj文件,并添加空的VSTest目标。
<Target Name="VSTest" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets" Condition="'$(MSBuildRuntimeType)' != 'Core' AND '$(WixTargetsPath)' == '' AND Exists('$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets')" />
<Target Name="EnsureWixToolsetInstalled" Condition="'$(MSBuildRuntimeType)' != 'Core' AND '$(WixTargetsImported)' != 'true'">
<Error Text="The WiX Toolset v3.11 (or newer) build tools must be installed to build this project. To download the WiX Toolset,see http://wixtoolset.org/releases/" />
</Target>
然后您可以使用以下命令行运行测试
dotnet test -v n --no-build