FAKE It Till You Make It
I’ve been studying build systems in .NET recently. I believe that automation is one of the most important pieces to any successful software project. Previously I wrote about Cake and how I liked the ease of use as well as how nice it was to contribute to the project. I mentioned in the comments of that post that I would be blogging about FAKE as well, and this post is that.
FAKE isn’t anything new. In fact, it’s been around for well over 5 years. Scott Hanselman had a really good post about it back in March of last year. If you’ve been keeping up, this will be nothing new, but for the readers that haven’t been following the activity, I hope my thoughts about it will be helpful to you.
Last week I presented at Headspring on this same topic with Patrick. Patrick is a fan of FAKE and I won’t speak for him, but I’m fairly certain he agrees with me in that I’d like to see more people and teams using it. There were two objectives to the presentation:
- Introduce FAKE to those that aren’t familiar.
- Convince people to give it a shot.
Now I can’t make you or my coworkers use it; that’s not the point. I just want to show you what you may be missing and let you choose your own build strategy from here on. I like FAKE and think it’s the best solution to the build and automation problem we face in .NET every day. I’d like to go over a few reasons why I think so. Before I do that, I’m going to talk about a few reasons why you shouldn’t use it.
Why You Shouldn’t be Using FAKE
You’re a Pro at PowerShell
You can whip together some PS code in no time. You never forget the equality operators, you even know the commands for file manipulation without having to Google them. That’s awesome and I wish I had the same skills as you. PowerShell is a very powerful language and can do a ton of amazing things! I don’t want to take anything away from PowerShell, but I don’t spend a lot of time in it. Because of this, I’m not nearly as efficient when writing it. If you have no problems with these things, this post might not be for you, sorry I can’t give you much to read about.
If, however, you have the same problems I have, maybe you should keep going.
You Don’t Want to Write F
The assumption that you need to be proficient in F# to use FAKE is a false one. I hear this often and I don’t know where it came from, and I can only easily assume why. The good thing about FAKE is that it doesn’t require a deep understanding of F#. It’s a DSL built on F# and writing FAKE is much different, I’ll say easier, than writing F#.
You’ve Adopted Gulp/Grunt
Why You Should be Using FAKE
It’s Best of Breed in .NET
There are several build tools out there, but through all the ones I’ve used, FAKE is winning. It has the biggest community around it, most built-in features (that I’m aware of), it’s still actively developed and maintained, and runs on Linux.
The Help is Fantastic
When you need assistance, there are a lot of options available: great documentation, terrific responses on GitHub, and even Google and Stackoverflow are helpful. Oh, and let’s not forget the entire F# community!
Faster and Easier
I’m still no veteran when it comes to writing FAKE scripts, but I can honestly say that it’s far more of an efficient use of my time than any other build tool I’ve used. With all the “Helpers” (over 100 in fact) there’s not much that you have to write on your own. You’re literally just putting building blocks together in the order and direction you want them.
A Sample Script
Anyway, on with the sample code! This tiny little snippet comes directly from the FAKE site, and I’ll leave it with you and let you browse on over there to check out more samples since that won’t get out of date as fast as this may.
#r "tools/FAKE/tools/FakeLib.dll" // include Fake lib open Fake Target "Test" (fun _ -> trace "Testing stuff..." ) Target "Deploy" (fun _ -> trace "Heavy deploy action" ) "Test" // define the dependencies ==> "Deploy" Run "Deploy"
Like other FAKE fans, it’s one of those “why wasn’t I using this long ago?!” thoughts. I could keep going on, but I’ll let you check it out and form your own opinions. As somebody who doesn’t like to change things up too often, I’m VERY glad I’ve made the switch from PowerShell (in my case) to FAKE.