1

How to avoid Windows Installer Wix build when running dotnet test even with the --no-build flag? Even if Wix Tools are installed it still fails.

Command line

dotnet.exe test --configuration Release --no-build

Error

.msi.wixproj: error : The WiX Toolset v3.11 (or newer) build tools must be installed to build this project.
Xavier John
  • 8,474
  • 3
  • 37
  • 51
  • Not sure, but please verify that .NET 3.5 is installed. WiX 3 has a dependency on this .NET version, so you need to install it if it is not present on the box. [Please see this answer for the procedure](https://stackoverflow.com/a/54931394/129130). Don't forget the Windows Update part. – Stein Åsmul Aug 19 '20 at 08:14

1 Answers1

1

Here is a solution to the problem, use a flag to skip importing WixTools into the project by using an MSBuild reserved keyword MSBuildRuntimeType.

You have to modify .wixproj file as follows and also add the empty VSTest Target.

<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>

You can then run the test using the following command line

dotnet test -v n --no-build
Xavier John
  • 8,474
  • 3
  • 37
  • 51
  • 1
    For documentation on **MSBuildRuntimeType** and its possible values, see https://learn.microsoft.com/en-us/visualstudio/msbuild/msbuild-reserved-and-well-known-properties – Chris Martinez Oct 01 '20 at 00:51