How do I pass my own custom arguments to build.ps1?
Asked Answered
R

2

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".

Rase answered 14/10, 2016 at 15:23 Comment(0)
A
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.

Audwin answered 14/10, 2016 at 15:27 Comment(5)
Thanks! that sorted it.Rase
Yes: powershell -File build.ps1 -ScriptArgs '--deployEnv=st','--bldversion=1.2.3'Frederico
@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'Ophiolatry
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.Buchner
I wonder if 'version' is a reserved argument. I received the same error message "Error: Argument value is not a valid boolean value.".... This works for me in my build.cake file var version = Argument<string>("build_version", "1.0.0"); And passing the argument .\build.ps1 -ScriptArgs --build_version=999.999.999Reichsmark
M
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

Marketable answered 14/10, 2016 at 18:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.