FAKE 5 - Custom Modules
INFO
This documentation is for FAKE.exe before version 5 (or the non-netcore version). The documentation needs te be updated, please help!
"FAKE - F# Make" is intended to be an extensible build framework and therefore it should be as easy as possible to create custom tasks. This tutorial shows how to create a (very simple) custom task in C#. The same works for other .NET language like Visual Basic or F#.
Creating a custom task
Open Visual Studio and create a new C# class library called my MyCustomTask and create a class called RandomNumberTask:
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: |
|
Now you can build, package and upload your build task to a NuGet feed. There are no special requirements, you can add dependencies to your NuGet package and define the API however you like.
Note: As FAKE 5 currently is a
netcoreapp20
application you need to provide a binary in your NuGet package compatible with netcore. We suggest targettingnetstandard20
or lower. as we update to newer netcore versions from time to time you should re-check and open a PR to change this text if it is outdated. (Just edit here with the pencil)
If you want to use FAKE's standard functionality (like globbing) within your CustomTask project, just reference the corresponding NuGet package and explore the FAKE namespace.
Using the custom task
Assume you pushed your custom task as MyTaskNuGetPackage
to NuGet.
Now you can use your CustomTask in the build script, by adding the
1:
|
|
to your fake dependencies, see the relevant documentation for adding modules. This documentation now applies to your package too! One example would be:
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: |
|