Getting started with C# script in your client-side git hooks

Why use hooks?

We, as developers, love platforms like GitHub, GitLab, Atlassian, Azure DevOps etc., as our managed git system and collaboration platform. We also love clean code and keep inventing new linters and rules to enforce it. In my opinion, every commit should allow the codebase to deploy to production. There is nothing worse than commits like “fixed style errors” or “fixed build”. These are often small mistakes you want to know as early as possible in your development cycle. You don’t want to break the build for the next developer because he pulled your ‘mistake’ or waste precious build minutes of…

There are many ways to structure your projects source code. My preference is a style called single-solution-model. Amongst other things, I like that it provides a single entry point to my project. If, however, your project grows, it can become slow to build it. I am sure some of you will be familiar with the following xkcd joke or some variant of it:

I’ve recently worked on a project where I was the consumer of a third party API. Luckily for me, we decided on an Open API specification which made integrating services a breeze. If you have been following my content, you know I often use C# in my projects. So I needed a type-safe client for use in my C# code base.

To accomplish my goals, I used the NSwag library created by Rico Suter. This project provides me with an MSBuild task for generating clients. In my case, I used a JSON file version to generate my client. …

Recently I was looking into a new way to use mocks in my unit tests. My framework of choice to write unit tests is XUnit, whereas I use Moq to create Mocks. The theory behind Moq will still apply if you use a different testing framework, and perhaps some of the things I will demonstrate will be possible in other mocking frameworks.

In many projects, I find that we look at essential things like:

  • How should the architecture look?
  • Which design patterns should we use?
  • Making sure we follow the SOLID principles.
  • How should we structure our code base?


For .NET, the standard mechanism for sharing packages is NuGet. A .nupkg file is an archive that contains your compiled code (DLLs), other files related to your code, and a manifest containing metadata (source). This blog post will show you how data in this manifest can be controlled by using MSBuild.

For simplification purposes, my sample project will consist of only a single class library project. I like you to keep in mind that this would scale to many projects as Microsoft did with the “Microsoft.Extensions packages”. The sky is the limit.

There are bits of this demo that work…

Max Hamulyák

Building a solid solution is more important than the technology used | Kaylumah

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store