Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accessing script arguments #2125

Closed
mac10688 opened this issue Oct 6, 2018 · 4 comments
Closed

Accessing script arguments #2125

mac10688 opened this issue Oct 6, 2018 · 4 comments

Comments

@mac10688
Copy link

mac10688 commented Oct 6, 2018

Description

I would like to access arguments passed in via command line with my build script.

Repro steps

Please provide the steps required to reproduce the problem

  1. Create test.fsx

  2. Insert the following code

#load ".fake/build.fsx/intellisense.fsx"
open Fake.Core

Trace.log(Environment.environVarOrFail "config")
  1. Call script with

./.fake/fake run test.fsx config=test

Expected behavior

The variable config will be found and trace.log will print test

Actual behavior

The call fails to find config.

Known workarounds

I will need to set the config as an environment variable.

export config=test

Related information

  • Operating system: macOS High Sierra
  • Branch: master?
  • .NET Runtime, CoreCLR or Mono Version: Mono
  • Indications of severity: Annoying
  • Version of FAKE (4.X, 5.X): 5
  • (if performance issue) Performance information, links to performance testing scripts
@matthid
Copy link
Member

matthid commented Oct 7, 2018

There are several ways to do this:

Hope this clarifies the situation. Feel free to leave suggestions on how to improve the documentation or implementation.

@mac10688
Copy link
Author

mac10688 commented Oct 7, 2018

Oh ok. I can do that. I'm not sure what Fake.Core.Target is. I was hesitant to do this because I didn't want to set global state in my shell. I don't know what the scope of setting an environment variable is so I was afraid of what happened if two builds kicked off at one time. One for production and one for qa. I'm using teamcity to build it and you don't seem to have an issue with it so I will do this. Thank you for your help.

I wonder if something has changed since this answer was posted on SO.

https://stackoverflow.com/questions/26267601/can-i-pass-a-parameter-to-a-f-fake-build-script/26597179#comment92276935_26597179

@matthid
Copy link
Member

matthid commented Oct 8, 2018

@mac10688 Yes try to get some docs for the shell you are using most have a syntax to set environment variables for the current session only or even for a single command (for bash it's just setting the variables before the command on the same line see my example)

@matthid
Copy link
Member

matthid commented Oct 8, 2018

@mac10688 yes that SO answer is outdated as both the cli as well as the APIs changed. Please feel free to add another answer...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants