This project has moved and is read-only. For the latest updates, please go here.


Switch Parameters not working properly


I tried to use this module to help with my build and I am receiving errors.

The first was that PassThru was not defined which based on the definition it should not need to be defined.

Here is how I was calling it without the definition:

<path>\my.csproj is place holder so no items that should not be shared get shared. Replace with any csproj path that works for you.

$result = Invoke-MsBuild -Path "<path>\my.csproj" -BuildLogDirectoryPath "$scriptPath" -Params "/property:Configuration=Release"

This returns the error:

Invoke-MsBuild : Unexpect error occured while building "<path>\my.csproj": The variable
'$PassThru' cannot be retrieved because it has not been set.
At build.ps1:84 char:25
  • $result = Invoke-MsBuild <<<< -Path "<path>\my.csproj" -BuildLogDirectoryPath "$scriptPath" -Pa
    rams "/property:Configuration=Release"
    • CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
    • FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Invoke-MsBuild
So I looked into the file and didn't see anything that jumps out at me so I tried to specify it manually like so:

$result = Invoke-MsBuild -Path "<path>\my.csproj" -BuildLogDirectoryPath "$scriptPath" -Params "/property:Configuration=Release" -PassThru:$false

Once I do that I get another error:

The variable '$KeepBuildLogOnSuccessfulBuilds' cannot be retrieved because it has not been set.
At Invoke-MsBuild.psm1:269 char:40
  • if (!$KeepBuildLogOnSuccessfulBuilds <<<< )
    • CategoryInfo : InvalidOperation: (KeepBuildLogOnSuccessfulBuilds:Token) [], RuntimeException
    • FullyQualifiedErrorId : VariableIsUndefined
So next I try to specify that using similar to -PassThru:$false but it won't let me. I tried the fully qualified value, Keep, K, etc. they all just fail.

Any thoughts on this. I'm not a powershell expert by any means but that's what I'm getting.

I'm running on Windows 7 in the 64 bit ISE.
Closed Oct 25, 2013 at 11:27 PM by deadlydog
Fixed script to make it PowerShell v2.0 compatible.


SaxarBattleCow wrote Oct 22, 2013 at 5:41 AM

I had this same issue, and after a while determined that this module requires Powershell 3.0 or later, which is step over the 2.0 that comes built into Windows 7.

Recommend updated requirements on Codeplex.

deadlydog wrote Oct 22, 2013 at 6:30 PM

Sorry, I only just saw this issue today. As @SaxarBattleCow suggests I'll update the requirements on the Website until I have a chance to see if I can refactor the script to make it PowerShell v2.0 compatible (if possible). Thanks.

deadlydog wrote Oct 22, 2013 at 6:31 PM

Oh, and @jcauble, if possible can you try updating to PowerShell v3.0 and see if this resolves the problem for you please.

deadlydog wrote Oct 25, 2013 at 11:28 PM

Fixed in v1.3 which made the script PowerShell v2.0 compatible.