DEV Community

Simon Reynolds
Simon Reynolds

Posted on • Originally published at simonreynolds.ie on

MiniScaffold, setting up a new F# project the easy way

MiniScaffold, setting up a new F# project the easy way

Setting up a new project can be a pain. Especially if you want to split it into separate folders for clarity. You might want a src folder for the project itself, a test folder for the unit and integration tests, a docs folder for documentation. You are writing documentation for your work, right?

MiniScaffold, setting up a new F# project the easy way
Of course I always do too

If you're writing in F# you've probably long ago moved from NuGet to Paket, but the standard .NET templates still use NuGet so that has to be migrated. There's build scripts to write too. It could be an hour or more of work before you start working on the code you actually wanted to write.

Enter MiniScaffold, a dotnet template that is for creating and publishing applications (supporting .NET Core 3.1) and libraries (supporting both .NETStandard 2.1 and .NET Framework 4.6.1

It's designed and built to take care of the humdrum for you, it gives you

  • a clean and well separated folder structure
  • a matching .gitignore file
  • an .editorconfig file tweaked for F# development
  • configures CI builds on Appveyor (for Windows) and TravisCI (for Linux and macOS)
  • fully configured build scripts using FAKE
  • integrated package management with Paket
  • integrated unit testing (Expecto) and code coverage reports (AltCover/ReportGenerator)
  • automatic code formatting with Fantomas

And that's just to get started, also included is a file named CHANGELOG.md. All you have to do is keep it updated with your notable changes, even reference the associated pull requests for those changes.

The generated build scripts include a Release action that will parse the CHANGELOG.md file, create a tag in GitHub with the version number specified, update any pull requests mentioned with the version number, publish a GitHub release for the version and even include any build artifacts in the dist folder! Doing all that is as easy as typing seven extra characters

# Development build
./build.sh

# Release build
./build.sh Release
Enter fullscreen mode Exit fullscreen mode

It's certainly an opiniated template, if you really wanted to go with a different test library for example, you'd have enough repeated work changing it each time that it would probably be better to fork the github project and customise it yourself. But I'd recommend trying it out first, it becomes second nature and is now my go to template for all F# projects!

To get started, install the template

dotnet new -i "MiniScaffold::*"
Enter fullscreen mode Exit fullscreen mode

Then go with

# I'm building a library
dotnet new mini-scaffold -n MyCoolNewLib --githubUsername MyGithubUsername

# I'm building an application
dotnet new mini-scaffold -n MyCoolNewApp --githubUsername MyGithubUsername -ou console
Enter fullscreen mode Exit fullscreen mode

The author of this template, Jimmy Byrd, has clearly put an incredible amount of effort into this and it is a great example of how creating a template (or any project) to simplify some repetitive task is always worth sharing with the community.

Top comments (1)

Collapse
 
shimmer profile image
Brian Berns • Edited

I do most of my work in F#, but I'm still an old-fashioned Visual Studio guy. I just pick a template in VS (e.g. .NET Core class library) and start coding. If I want unit tests, I create a second project in the same solution. I know I'm in the minority, but it seems so much simpler to me than what you describe here. Can you explain why I'd want to move to Paket or any of the other things you've mentioned (FAKE, Expecto, etc.)? It seems like a lot of extra work (not to mention the additional cognitive load), and I haven't even heard of most of them.