Question

I'm trying to create build scripts with psake for our company C# project in .NET 3.5, but when I run it, it fails with errors

default parameter specifiers are not permitted

I google out and it looks like it is a problem of .NET 3.5 that does not allow default parameters in functions.

However it is strange that same project built with msbuild.exe has succeeded. I tried to set $framework variable of psake to '3.5x86' and '3.5x64' but none of that helps.

Do you have any idea what is wrong with psake or if there is an secret variable that I'm missing?

My psake script:

$scriptDir = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent

$framework = '3.5x86'

$serverSln = $scriptDir+'\..\Server\Server.sln'
$clientSln = $scriptDir+'\..\Client\Client.sln'
$outDirServer = $scriptDir+'\..\Binaries\Server'
$outDirClient = $scriptDir+'\..\Binaries\Client'


task default -depends Full
task Full -depends Clean, BuildServer, BuildClient #, BuildAccs, DeployRelease

task BuildServer {
  #Framework '3.5'
  exec { msbuild $serverSln /t:Build /p:Configuration=Release /v:quiet }
}

task BuildClient {

  #Framework '3.5'
  exec { msbuild $clientSln /t:Build /p:Configuration=Deploy /v:quiet }
  exec { msbuild $clientSln /t:Build /p:Configuration=Release /v:quiet }
}

task Clean {
  Write-Host Cleaning

  if (Test-Path $outDirClient) 
    {   
        rd $outDirClient -rec -force | out-null
    }

  if (Test-Path $outDirServer) 
    {   
        rd $outDirServer -rec -force | out-null
    }
}

Output of script:

$scriptDir = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent

$framework = '3.5x86'

$serverSln = $scriptDir+'\..\Server\Server.sln'
$clientSln = $scriptDir+'\..\Client\Client.sln'
$outDirServer = $scriptDir+'\..\Binaries\Server'
$outDirClient = $scriptDir+'\..\Binaries\Client'


task default -depends Full
task Full -depends Clean, BuildServer, BuildClient #, BuildAccs, DeployRelease

task BuildServer {
  #Framework '3.5'
  exec { msbuild $serverSln /t:Build /p:Configuration=Release /v:quiet }
}

task BuildClient {

  #Framework '3.5'
  exec { msbuild $clientSln /t:Build /p:Configuration=Deploy /v:quiet }
  exec { msbuild $clientSln /t:Build /p:Configuration=Release /v:quiet }
}

task Clean {
  Write-Host Cleaning

  if (Test-Path $outDirClient) 
    {   
        rd $outDirClient -rec -force | out-null
    }

  if (Test-Path $outDirServer) 
    {   
        rd $outDirServer -rec -force | out-null
    }
}
Was it helpful?

Solution 2

I finally found a bug between keyboard and chair. After I deleted obj files of project that was created by .NET 4.0, the MSBuild.exe keeps failing on same error. So there is no bug in psake and it is still great :)

OTHER TIPS

The $framework variable is deprecated in latest versions, you should use the framework function instead. But it apparently does not work. It looks like a bug in PSake.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top