Build file required when running psake

108 views
Skip to first unread message

Joe Young

unread,
Aug 12, 2013, 2:00:04 PM8/12/13
to psake...@googlegroups.com
I'm new to psake and trying to get my head wrapped around it.

When executing psake from the command line (powershell) do you always have to specify the build file as in

.\psake default.ps1 Build

I have noticed that if I do not specify the file I get an error but psake keeps on running.

If I don't specify a build file and task it works with no error: .\psake  
If I specify a task an no build file I get the below error: .\psake Build
If I specific a task and build file then it works with no error: .\psake default.ps1 Build

Test-Path : The given path's format is not supported.
At C:\users\jyoung\projects\MyProject-Specifications\psake.ps1:40 char:18
+     if (test-path <<<<  $absoluteBuildFile)    {
    + CategoryInfo          : InvalidOperation: (C:\users\jyoung...ons\Build:String) [Test-Path], NotSupportedException
    + FullyQualifiedErrorId : ItemExistsNotSupportedError,Microsoft.PowerShell.Commands.TestPathCommand

So if you want to run a specific task, you need to specify the build file.

It looks like in psake.ps1 if I don't specify the build file then it thinks the build file is the task.

Is this intended? Looking through psake.ps1 and psake.config, they both indicate or default the build file to "default.ps1" but I still have to put it on the command line?

Thanks,
Joe


Jonathan Matheus

unread,
Aug 12, 2013, 7:29:02 PM8/12/13
to psake...@googlegroups.com
Hey Joe,
This is a powershell thing. If you look in psake.ps1, you should see something along the lines of:

param(
    [Parameter(Position=0,Mandatory=0)]
    [string]$buildFile = 'default.ps1',
    [Parameter(Position=1,Mandatory=0)]
    [string[]]$taskList = @(),
    [Parameter(Position=2,Mandatory=0)]
    [string]$framework,
    [Parameter(Position=3,Mandatory=0)]
    [switch]$docs = $false,
    [Parameter(Position=4,Mandatory=0)]
    [System.Collections.Hashtable]$parameters = @{},
    [Parameter(Position=5, Mandatory=0)]
    [System.Collections.Hashtable]$properties = @{},
    [Parameter(Position=6, Mandatory=0)]
    [alias("init")]
    [scriptblock]$initialization = {},
    [Parameter(Position=7, Mandatory=0)]
    [switch]$nologo = $false,
    [Parameter(Position=8, Mandatory=0)]
    [switch]$help = $false,
    [Parameter(Position=9, Mandatory=0)]
    [string]$scriptPath = $(Split-Path -parent $MyInvocation.MyCommand.path)
)

this is how powershell defines function parameters. If you want to specify a parameter, just specify it by name:

.\psake.ps1 -taskList Build

Good luck!
Jonathan


--
You received this message because you are subscribed to the Google Groups "psake-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to psake-users...@googlegroups.com.
To post to this group, send email to psake...@googlegroups.com.
Visit this group at http://groups.google.com/group/psake-users.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages