Olaf
Olaf

Reputation: 3986

FAKE: Target prints all available targets in build script

Question: Is there a command in FAKE available which prints all the defined targets in the build script?

I want to setup my FAKE build in such a way that it prints a list of all available targets in the build script when I do not specify a target.

For example:

> build.cmd

Available targets:
  - Clean
     Depends on: []
  - DeleteBinObj
     Depends on: []
  - RestorePackages
     Depends on: ["Clean"]
  - Build
     Depends on: ["RestorePackages"]
  - CopyBinaries
     Depends on: ["RunTests"]
  - RunTests
     Depends on: ["Build"]
  - Default
     Depends on: ["CopyBinaries"]

In the FAKE build script I would define something like:

Target "Default" (fun _ ->
    listTargets
)

RunTargetOrDefault "Default"

The only thing that is missing it the command listTargets.

Upvotes: 2

Views: 338

Answers (1)

hvester
hvester

Reputation: 1628

In your build.cmd replace

packages\FAKE\tools\FAKE.exe build.fsx %*

with

if [%1] == [] (
    packages\FAKE\tools\FAKE.exe build.fsx --listTargets
) else (
    packages\FAKE\tools\FAKE.exe build.fsx %*
)

Upvotes: 5

Related Questions