Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Environment variables passed in command line are not evaluated until targets execution #2283
If I pass custom build parameters using "-e" switch they are not evaluated until targets are selected for execution. This makes it impossible to configure conditional target execution based on command line parameters.
Let's say I have a script that contains the following lines:
let skipTests = Environment.environVarAsBoolOrDefault "skipTests" false
I run the script:
fake run build.fsx --target All -e skipTests=true
I expect "skipTests" to be evaluated at the time target execution is decided, i.e. the statement
Please provide a description of the behavior you expect.
At the time ("RunTests", not skipTests) is evaluated, skipTests is "false". Only inside the actual RunTests target execution "skipTests" is evaluated to "true".
IMHO it would make sense to enable evaluation of environment variable early. Current behavior doesn't look consistent for two reasons.
I haven't inspected the implementation but what makes it delay evaluation of environment values sent via command line? It would makes things more consistent if they became available at the beginning of the script execution.
And if it's hard to make environment variables evaluated at the very beginning of the script, at least there should be a way to evaluate them in a target dependency section, so "condition" part can be specified as a predicate, not only a boolean value. This will still leave inconsistent mismatch between OS-level variables and command line variables, as described in p.2 above.
It's basically the split of the command line. The script arguments (which includes the
Yes that was my suggestion: Add a new API which can be called at the top of the script. At least that would be the easiest approach afaics.
One other workaround/related feature now in Fake 5 is you add your very own CLI: https://fake.build/core-commandlineparsing.html