question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow users to use any of the Cake runner arguments as build script arguments

See original GitHub issue

Background

The Cake runner supports a number of arguments, such --version to display the version of the runner, or --debug to launch the script in debug mode.

However, this make it impossible for these names to be used as arguments in Cake build scripts. For example, if one wanted to use the argument version as an input to the build script:

var version = Argument<string>("version");

And then run Cake:

dotnet cake --version=1.2.3

They would receive an error: Flags cannot be assigned a value

Workaround

The current workaround is to use the “remaining arguments” feature when using one of these “reserved” argument names:

dotnet cake -- --version=1.2.3

Proposal

This issue intends to make the necessary updates to allow existing “flag” arguments to be used in build scripts, so that if the user runs cake with --version=1.2.3 do not assume the flag --version and instead execute the Cake script with the argument ["version"] = "1.2.3".

Command-line Expected result
dotnet cake --version Display Cake version (as it is today)
dotnet cake --version=1.2.3 Run build script and set the version argument to 1.2.3

This should work for all Cake runner arguments, except for Verbosity which is not a “flag” argument.

image


Related:

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:16 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
FrankRay78commented, Dec 11, 2022

I have implemented the change to allow flags to be converted to remaining arguments if they cannot be assigned, and submitted the PR for this: https://github.com/spectreconsole/spectre.console/pull/1102

Once merged and a new version of spectre.console is available, turning this behaviour on should be a 1 line code change in the cake codebase 🙂

1reaction
FrankRay78commented, Mar 1, 2023

Update @augustoproiete - I have asked the maintainers of spectre to prioritise the above PR, so once merged, hopefully I can address this cake issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

cakebuild - Pass multiple parameters/arguments to target
I am going to assume that you are using the latest bootstrapper file, which is available from here:.
Read more >
Running Targets
When using Cake .NET Tool you can use the RunTarget method to run a target. ... All arguments passed to Cake will also...
Read more >
Running Cake in Azure Pipelines and accounting for optional ...
Well, the answer is easy: In Cake , you can define arguments (with default values) and these arguments can be (optionally) overridden when ......
Read more >
Using Cake build scripts for your .NET Core web apps
Cake is a build automation system for .NET Developers to script their build processes using a C# Domain Specific Language (DSL).
Read more >
Deploying a .NET Core 2 app to a Raspberry Pi with Cake and ...
I've always just supplied my Raspberry Pi's IP address and username through configurable parameters in the build.cake script, as shown below. // ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found