cake: Bug? "More than one build script specified" when calling build.ps1 with a custom cake script and extra parameters

What You Are Seeing?

When I specify a custom cake script with extra parameters using the build.ps1 bootstrap file, I get the following error:

More than one build script specified.

Note: If I remove the extra parameter that I would like to pass to my script everything works

What is Expected?

Cake executes using the custom cake script file

What version of Cake are you using?

0.13.0

Are you running on a 32 or 64 bit system?

64

What environment are you running on? Windows? Linux? Mac?

Windows

Are you running on a CI Server? If so, which one?

None

How Did You Get This To Happen? (Steps to Reproduce)

.\build.ps1 -Script “3rdPartyPackages.cake” -Settings=3rdPartyPackages.settings.json

Output Log

.\build.ps1 -Script "3rdPartyPackages.cake" -Settings="3rdPartyPackages.settings.json"
Preparing to run build script (3rdPartyPackages.cake)...
Running build script...
& "E:\Projects\tools\Cake\Cake.exe" "3rdPartyPackages.cake" -target="Default" -configuration="Release" -verbosity="Verbose"    -Settings=3rdPartyPackages.settin
gs\.json
More than one build script specified.

Usage: Cake.exe [build-script] [-verbosity=value]
                [-showdescription] [-dryrun] [..]

About this issue

  • Original URL
  • State: open
  • Created 8 years ago
  • Comments: 26 (9 by maintainers)

Most upvoted comments

Ugh, I just found #1690 which suggests the syntax I need is --target=Clean, which works fine. Seems like the main problem here is the confusing error message and the (lack of) docs.

I have seen this before, it seems to come from when the extra param value contains a ‘.’ > .\build.ps1 -Target "my-target" -Version="1.2.3"

this fails with the same output. from the notes i have on my fix, i looked at the cake source and see that the extra arguments will support ‘-’ or ‘–’ syntax.

i was able to change my use-case to the following to get it to work without modifying the build script or the underlying binary. > .\build.ps1 -Target "my-target" --Version="1.2.3"

this is with 0.15.2

@dasiths are you using the most recent version of the PowerShell bootstrapper?

Getting the same when trying to specify a target via build.sh:

> ./build.sh -target Clean
More than one build script specified.
For usage, use parameter --help
> ./build.sh --target Clean
More than one build script specified.
For usage, use parameter --help

And --help doesn’t even mention the ability to specify a target 😕 :

> ./build.sh --help

Usage: Cake.exe [script] [--verbosity=value]
                [--showdescription] [--dryrun] [..]

Example: Cake.exe
Example: Cake.exe build.cake --verbosity=quiet
Example: Cake.exe build.cake --showdescription

Options:
    --verbosity=value    Specifies the amount of information to be displayed.
                         (Quiet, Minimal, Normal, Verbose, Diagnostic)
    --debug              Performs a debug.
    --showdescription    Shows description about tasks.
    --dryrun             Performs a dry run.
    --version            Displays version information.
    --help               Displays usage information.

Here is relevant --version output:

Version 0.28.1+Branch.main.Sha.1da1ea266471a2bb8034fc4a89017b5dcf455268
Running on .NET Core

Actually I think the fix is even simpler in my case, the default build.ps1 isn’t reading the $Script variable as a parameter. It just defaults: [CmdletBinding()] Param( [string]$Script = "build.cake",

Removed default: [CmdletBinding()] Param( [string]$Script,

It is now running the cake script that I pass in as a parameter

Tried all the variations on this page, none worked. This is what finally worked for us:

.\build.ps1 --% --ScriptArgs @('--targetTargetName','--exclusive','--buildUrl=%teamcity.serverUrl%/viewLog.html?buildId=%teamcity.build.id%&buildTypeId=%system.teamcity.buildType.id%')

The --% tells powershell to stop parsing text (ref: https://slai.github.io/posts/powershell-and-external-commands-done-right/) and the @(‘’,‘’,‘’…) notation is a command line string array (ref: https://www.varonis.com/blog/powershell-array/). As you can see, this was used in TeamCity and we have a url as a parameter, which complicated things.

@dasiths glad to hear that you were able to get this working.

This still appears to be broken…

@nate-datafinch If you’re using TeamCity then it could be because TeamCity appears to pass script arguments to powershell as a comma separated list, which breaks arguments that need to be passed as an array (like ScriptArgs).

I got around this by avoiding the TeamCity Powershell runner and just calling powershell directly from a command line task, e.g.:

powershell -NoProfile -NonInteractive -ExecutionPolicy ByPass -File ./build.ps1 --target=Default --buildVersion=1.0.0.577