Português English
My C# Maestro feature
2023.06.25

My C# Maestro

PortuguêsEnglish

I’ve always been obsessed with one thing: consistency. Whether I’m building code on my local machine or watching it run in the belly of a GitLab runner, I want the exact same behavior. I wanted a build process that didn’t care where it was—it should be just as comfortable on my laptop as it is on a third-party server.

When I started the SuCoS project, I knew I needed a build system that could match my ambition. It wasn’t just about compiling and testing; I wanted it to handle everything—generating tags, creating releases, and even cooking up a fresh Docker image every week.

After several late-night coding sessions—the kind fueled by too many coffee cups and far too many crumpled design sketches—I finally found my answer in Nuke. Instead of scattering my pipeline across a dozen separate stages in GitLab’s YAML, I let Nuke step in as my omnipotent orchestrator.

The Maestro in C#

At its heart, Nuke is an automation maestro. It’s like having a conductor for your code, ensuring every task is performed at the perfect moment. And the best part? This maestro speaks my favorite language: C#.

Before Nuke, I had to manually command GitLab to execute every step—dotnet restore, dotnet clean, dotnet build, dotnet test. Now, I just tell GitLab one thing: nuke test. That master command is like a potent incantation that triggers Nuke to handle everything else.

Since it’s written in C# instead of messy YAML, I have way more confidence in my builds. C# gives me that sense of solidity I crave. I love the fact that when I call nuke, the first thing it does is compile itself before building anything else. It’s a self-affirming echo that makes me feel right at home.

To keep things tidy, I also brought in GitVersion to handle Semantic Versioning (SemVer). It’s like having a diligent librarian who examines my commits, applies the Semantic Commit standards, and assigns the perfect version number without me lifting a finger.

Taming the Beast

Of course, no journey is without its bumps. While Nuke is powerful, I hit a few snags along the way.

Some tasks, like creating tags and releases, are very GitLab-centric and rely on their API. This means they aren’t quite as portable as I’d like and required some extra tinkering to get right. It was a small price to pay for the automation I gained.

As SuCoS grew, my build class started growing like a weed. It was becoming a nightmare to manage—a real “herding cats” situation. My solution? I split the class Build : Nuke into several partial classes. This turned an unruly mob of code into a disciplined, organized team. Now, my build logic is clean and easy to navigate.

The beauty of this setup is that if anyone forks SuCoS on GitHub, the build system will still work almost flawlessly with just a few minor tweaks.

Csharp nuke building system


Bruno MASSA