Wednesday, April 6, 2016

psake and curly braces

I was recently writing a psake script with its corresponding tasks and I decided to do some formatting of my tasks by moving the curly braces ({) onto a separate line consistent with what I follow when I am writing my C# code similar to this:


$testMessage = "This is from psake"

task Test  
{
    Write-Host $testMessage
}

Unexpectedly, this caused psake to no longer function correctly!

Since I had always seen psake formatted like this, I reverted it to this format:


$testMessage = "This is from psake"

task Test  {
    Write-Host $testMessage
}

Once I reverted the script back to the curly braces on the same line as the task, my psake scripts once again began working correctly!

Therefore, when you are working with your own psake scripts, make sure you keep your curly braces on the same line!!


No comments:

Post a Comment