Can I pass a parameter to a F# FAKE build script?

2019-04-03 05:41发布

I'm just getting started with FAKE. I really like the idea. In the tutorials the set the build and deploy directories.

// Directories
let buildDir  = "./build/"
let testDir   = "./test/"
let deployDir = "./deploy/"

and then later reference those which is fine, but is it possible to pass that as a parameter? Maybe to as Task where I can use it later?

标签: f# f#-fake
2条回答
太酷不给撩
2楼-- · 2019-04-03 06:06

Something like this should work.

From the command-line:

"..\packages\Fake.3.7.5\tools\Fake.exe" "build.fsx" dir=my/custom/dir/

In the build.fsx script:

let buildDir = getBuildParamOrDefault "dir" "./build/"

That will look for the dir parameter being passed in, and use it if it's assigned, otherwise it will default to ./build/

查看更多
你好瞎i
3楼-- · 2019-04-03 06:21

This answer accepted doesn't seem to work for FAKE 5.

You will want to set the environment variable before running the script.

dir=my/custom/dir/ ./fake.sh run build.fsx

As linked in the comments above.

http://www.github.com/fsharp/FAKE/issues/2125#issuecomment-427684505

查看更多
登录 后发表回答