Closed phil-scott-78 closed 4 years ago
Perhaps an ever easier solution would be to remove all the PowerShell arguments to the bootstrapper so there's a 1:1 mapping with Cake.
build.ps1 --verbosity=diagnostic --foo=bar
Not saying that we should do that (need some discussion) but our goal is to make the bootstrappers simpler and this would be a step in that direction.
@cake-build/team Any thoughts about this?
@patriksvensson - sorry for the delay getting back. Internet connection was worse than expected while traveling. So I tossed the idea around but honestly I couldn't wrap my head around a way to handle it without breaking backwards compatibility with anyone that might be using the current powershell like syntax. All my attempts ended with a huge if statement mess with a nasty combination of string parsing and examining $MyInvocation
The big hurdle I encountered even when trying to rip out the powershell arguments is PS's insistence that it doesn't want to tell you about the quotes that might have been passed in on the command line. So if, for example, you passed in -file="hello.text"
then $args
is -file=hello.txt
. Without the quotes the cake.exe command line parser chokes on the .
$MyInvocation.Line
does have the quotes, but as I said then you get into the weird world of parsing that out. Much easier if you break backwards compatibility with the current script's parameter binding, but huge headache otherwise.
We did some maintenance work on this repo which included removing of the develop
branch which closed this PR.
@phil-scott-78 In the meantime Cake .NET Tool has been made the recommended approach for running Cake scripts. If you feel this is still an issue please start a discussion.
This is more of a request for comments, but I think it is a step in the right direction. Currently passing in parameters to a cake script from the powershell bootstrapper isn't consistent, plus kind of weird especially with handling filenames.
Let's take this "build" script
With the current implementation to run this script with diagnostic verbosity you must run to get this to work (note no equal after verbosity but required for the others)
Additionally, if you make any mistake it'll blindly pass those args in cake giving some less than helpful errors because cake expects things differently than the bootstrapper. Some of these error messages actually point you in the wrong direction (see the verbosity help that is outputted)
you get this output
Or if you don't properly quote the file name
you get this output
This change allows you to run
Looks more like powershell and still sends things into cake.exe as expected.
File.txt
will be properly quoted andsomeBool
will be sent assomeBool=true
. Not sure if I've caught all the edge cases here especially around what values need to be quoted, but I wanted to throw this out and see what you all think. I'll be away on holiday until the 1st but hopefully I'll be able to check in and answer any questions or get tweaks implemented if this is something valuable.