Use mspec-clr4.exe for .NET 4 assemblies

less than 1 minute read

Otherwise, you get an error like

19/03/2013 14:31:39: An Error Occurred:
Exec: Error executing command & $mspecPath @(dir "$buildFolder\*Tests*\*Tests*.dll") .
At D:\dev\Shared\Jwt\src\packages\psake.\tools\psake.psm1:139 char:14
+ throw <<<< ("Exec: " + $errorMessage)
+ CategoryInfo : OperationStopped: (Exec: Error exe...*Tests*.dll") .:String) [], RuntimeException
+ FullyQualifiedErrorId : Exec: Error executing command & $mspecPath @(dir "$buildFolder\*Tests*\*Tests*.dll") .

The error is slightly misleading as it's saying the problem is your powershell doesn't have .net 4 loaded.

It's true that Powershell 2 loads .NET 3.5 and doesn't support .NET 4, but as mspec.exe is just a executable, it should't be affected. So, use mspec-clr4, rather than mspec, if your test assemblies are built in .NET 4.

I've changed the $mspecPath.

[sourcecode language="powershell"]
$mspecPath = "$baseDir\src\packages\Machine.Specifications.0.5.12\tools\mspec-clr4.exe"