10

I tried build.ps1 -SettingsProfile "Customer", but it outputs

More than one build script specified.

In my Cake script I fetch via

Argument("SettingsProfile", "Default")

And if I skip the argument to build.ps1 then it'll work, but obviously becomes "Default".

devlead
  • 4,535
  • 11
  • 33

2 Answers2

17

I assume you’re using the default boostrapper. If so there’s a -ScriptArgs parameter you can use to pass your custom Cake arguments.

Cake arguments are not formatted like standard PowerShell parameters (-Key value) but as --Key="value" As such your scenario would look like this

.\build.ps1 -ScriptArgs '--SettingsProfile="Customer"'

Your Cake script argument usage looks fine, so above modification should solve your issue.

devlead
  • 4,535
  • 11
  • 33
  • Thanks! that sorted it. –  Oct 14 '16 at 15:42
  • 6
    Yes: powershell -File build.ps1 -ScriptArgs '--deployEnv=st','--bldversion=1.2.3' – John Korsnes May 23 '17 at 10:35
  • 2
    @JohnKorsnes: Using multiple args your way gives me a 'More than one build script specified' `powershell -File build.ps1 -ScriptArgs '--deploymentPackagePath=\\server\folder1','--releasePackagePath=\\server\folder2'` – debgz Jan 25 '19 at 09:50
  • It is stranger than so since `.\build.ps1 -ScriptArgs '--dir="../CompulsoryCow.Meta/CompulsoryCow.Meta"', '--proj="CompulsoryCow.Meta"' -Target Package` works while adding a third parameter `.\build.ps1 -ScriptArgs '--dir="../CompulsoryCow.Meta/CompulsoryCow.Meta"', '--proj="CompulsoryCow.Meta"', '--version="3.0.2"' -Target Package` results in a `Error: Argument value is not a valid boolean value.` – LosManos Jun 23 '19 at 21:25
1

Depending on how far you want to go as well, you also have the option of extending the bootstrapper to accept your input parameter as a PowerShell argument. There is a tutorial on how you can extend the bootstrapper here:

http://cakebuild.net/docs/tutorials/extending-the-bootstrapper

Gary Ewan Park
  • 13,805
  • 4
  • 29
  • 53