Running targets in "FAKE - F# Make"
Listing targets
Before running any specific target it is useful to know all the targets that are available in a build script. FAKE can list all the avaiable targets including the dependencies by running the following command:
- Fake.exe YourBuildScript -lt
The option -lt stands for "list targets". It is an abbreviation of the option --listTargets.
Running specific targets
FAKE has a special param "target" which can be used to run specific targets in a build. We assume the following build script:
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: |
|
Now we have the following options:
- Fake.exe "target=Build" --> starts the Build target and runs the dependency Clean
- Fake.exe Build --> starts the Build target and runs the dependency Clean
- Fake.exe Build --single-target --> starts only the Build target and runs no dependencies
- Fake.exe Build -st --> starts only the Build target and runs no dependencies
- Fake.exe --> starts the Deploy target (and runs the dependencies Clean and Build)
Final targets
Final targets can be used for TearDown functionality. These targets will be executed even if the build fails but have to be activated via ActivateFinalTarget().
1: 2: 3: 4: 5: 6: |
|
Build failure targets
Build failure targets can be used to execute tasks after a build failure. These targets will be executed only after a build failure but have to be activated via ActivateBuildFailureTarget().
1: 2: 3: 4: 5: 6: |
|
Visualising target dependencies
FAKE can output the graph of target dependencies in the DOT format, which can then be rendered to a PNG-file by Graphviz.
Specifying the command line option --dotGraph (short version: -dg) makes FAKE write the dependency graph to the standard output instead of building anything. This option only works when the build script contains a call like this:
1:
|
|
Example
Say, the build script build.fsx
defines the target dependencies as follows:
1: 2: 3: 4: 5: |
|
The following command saves the target dependency graph in the graph.png
file (PowerShell syntax):
1:
|
|
resulting in an image like this: