EasyBuild is a set of F# tools I maintain for building and releasing .NET and Fable projects.
You write the build as an F# console project, with typed paths and helpers for the tools it calls. The version number and the changelog come from your commit messages.
The packages
| Package | Kind | What it does |
|---|---|---|
| EasyBuild.FileSystemProvider | Type providers | Typed paths to the files and folders of your project |
| EasyBuild.Tools | Library | F# helpers for dotnet, Fable, npm, Vite, Git and other CLI tools |
| EasyBuild.CommitLinter | .NET tool | Checks that commit messages follow Conventional Commits (feat: ..., fix: ...) |
| EasyBuild.CommitParser | Library | Parses commit messages for the other tools, with clear error messages |
| EasyBuild.ShipIt | .NET tool | Computes versions, writes changelogs and opens the release pull request |
| EasyBuild.PackageReleaseNotes.Tasks | MSBuild tasks | Sets the package version and release notes from CHANGELOG.md |
A build project
Most EasyBuild repositories build with a console application in a build/ folder, started by a small script:
#!/bin/sh -x
dotnet tool restore
dotnet run --project build/EasyBuild.fsproj -- $@
./build.sh test runs the test command of that project, and ./build.sh release the release command.
Typed paths
EasyBuild.FileSystemProvider is a type provider: it reads the folders of your project at compile time and turns them into a type. A path that does not exist is a compile error:
[<Literal>]
let root = __SOURCE_DIRECTORY__ + "/../"
type Workspace = RelativeFileSystem<root>
type VirtualWorkspace =
VirtualFileSystem<
root,
"""
src
bin/
demo
dist/
"""
>
Workspace reads the folders on disk. VirtualWorkspace describes folders that are not tracked in the repository, like build output.
Helpers for the tools
EasyBuild.Tools wraps the CLI tools a build calls. This is part of the release command of EasyBuild.ShipIt's own build:
if Directory.Exists VirtualWorkspace.src.bin.``.`` then
Directory.Delete(VirtualWorkspace.src.bin.``.``, true)
let nupkgPath = DotNet.pack Workspace.src.``.``
DotNet.nugetPush nupkgPath
DotNet.nugetPush reads the API key from the NUGET_KEY environment variable when you do not pass one.
From commit to package
In the EasyBuild.ShipIt repository, a change goes through these steps:
Commit
A Git hook, installed with Husky.Net, runs CommitLinter on each commit message:
Terminal dotnet husky add commit-msg -c 'dotnet commit-linter "$1"'Prepare the release
On each push to
main, CI runs the tests, then ShipIt computes the next version, writes theCHANGELOG.mdentry and opens a release pull request.Pack
When that pull request is merged, CI runs
./build.sh release: the tests, thendotnet pack. PackageReleaseNotes.Tasks reads the latest entry ofCHANGELOG.mdand setsVersion,PackageVersionandPackageReleaseNotes. When the changelog is not next to the project file, point to it:src/EasyBuild.ShipIt.fsproj <PropertyGroup> <ChangelogFile>$(MSBuildThisFileDirectory)../CHANGELOG.md</ChangelogFile> </PropertyGroup>Publish
The build pushes the package to NuGet. The workflow gets a temporary API key through NuGet Trusted Publishing and passes it as
NUGET_KEY.
You can use each package on its own. FileSystemProvider is useful in any F# script that handles paths, and PackageReleaseNotes.Tasks works with a changelog you write yourself.