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

一笑奈何 提交于 2019-12-05 09:10:06

问题


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?


回答1:


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/




回答2:


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



来源:https://stackoverflow.com/questions/26267601/can-i-pass-a-parameter-to-a-f-fake-build-script

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!