Skip to content

Instantly share code, notes, and snippets.

@mastoj
Last active August 29, 2015 14:23
Show Gist options
  • Save mastoj/2a47953915c2698b9419 to your computer and use it in GitHub Desktop.
Save mastoj/2a47953915c2698b9419 to your computer and use it in GitHub Desktop.
FAKE question about parameters
@echo off
cls
"NuGet.exe" "Install" "FAKE" "-OutputDirectory" "packages" "-ExcludeVersion"
"packages\FAKE\tools\Fake.exe" build.fsx %*
pause
// include Fake lib
#r @"packages/FAKE/tools/FakeLib.dll"
open Fake
open Fake.EnvironmentHelper
// Default target
Target "Default" (fun _ ->
trace "Hello World from FAKE"
)
Target "Clean" (fun _ ->
printfn "Name = %s %s" (environVar "first") (environVar "last")
trace "Cleaning up your trash"
)
Target "Random" (fun _ ->
printfn "Name = %s %s" (environVar "first") (environVar "last")
trace "It's not really random"
)
Target "What" (fun _ ->
printfn "Has build param WAT? %A" (hasBuildParam "WAT")
printfn "Has build param YO? %A" (hasBuildParam "YO")
printfn "Has build param YOLO? %A" (hasBuildParam "YOLO")
printfn "Name = %s %s" (environVar "first") (environVar "last")
trace "What happened?"
)
// start build
printfn "Build is starting, sit down and enjoy the ride!"
"Clean"
==> "Default"
==> "Random"
==> "What"
RunTargetOrDefault "Default"
.\build.cmd What -ev first john -ev last doe
Prints:
Has build param WAT? false
Has build param YO? false
Has build param YOLO? false
Name = john doe
As expected. But this
.\build.cmd What -ev first john -ev last doe WAT YO
prints:
Has build param WAT? true
Has build param YO? true
Has build param YOLO? false
Name = true true
And this prints what I expect
.\build.cmd What first=john last=doe WAT YO
Prints
Has build param WAT? true
Has build param YO? true
Has build param YOLO? false
Name = john doe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment