Why you should automate your development environment setup

Michael Lehmann
Michael Lehmann23 June 20225 min read

Setting up a development environment for a new project is not one of the most popular tasks. As a new developer in the project, you don't know the environment and have to work through pages and pages of documentation until your own development environment is up and running. Experience shows that such documentations are often not up to date. This leads to a lot of trial and error and asking questions. In the end, it often takes several hours or sometimes more than a day before you can start developing.

This can be very frustrating and we even haven't talked about repeating this when you are working in a micro-service based project or want to flush your dev env setup.

I'm working in lots of self-contained systems and micro service based projects. And it can happen that I need to switch those projects several times a week. So it is crucial for me to avoid such wasted time. I automate the dev env setup as much as possible and keep improving it. With this approach you can get up and running within minutes!

Use docker to install your infrastructure

First of all we can avoid to install a huge list of software infrastructure, such as SQL Server, Message Broker, SMTP Client, Identity Provider etc. All this can be setup by using docker.

Using docker has several advantages:

  • You don't pollute your operating systems with this applications. Even when you uninstall them, some relict be left in your system.
  • Everyone in the team has exactly the same versions of the infrastructure.
  • Everyone in the team automatically get additional infrastructure, without installing them manually.
  • You can get and run this software within minutes, it actually only needs one command to start them all.

Using docker reduces the list of software to install to the following and this is something which will be the same for all of your projects, so you do it only once:

  • GIT (or your preferred source version control system)
  • Docker Desktop
  • SDK's (Usually .Net Core and Node)
  • IDE (In my case Visual Studio, Rider or whatever)

And than I prepare a docker compose file, containing all required infrastructure, in the root of the SVC repository:

version: "3.8"

    container_name: mssql
      - 1433:1433
      - SA_PASSWORD=<any password>
      - TZ=Europe/Zurich
      - local-dev-sql:/var/opt/mssql

    container_name: azurite
      - 10000:10000
      - 10001:10001
      - 10002:10002
      - local-dev-azurite:/data

    container_name: smtp
    image: rnwood/smtp4dev:v3.1
      - "6200:80"
      - "2525:25"


And it will require only one command to start up everything:

docker-compose -f -p my-app up

You can flush your infrastructure with only one command as well:

docker-compose -f -p my-app down -v

Script application specific configurations and setups with Nuke

The first part of your dev env setup is done with that. Usually there needs to be done more. Things like local configurations, database setup, etc.

A few years ago, I stumbled over Nuke. A build scripting engine running plain .Net code and is fully integrated in your .Net development IDE. Everyone in our teams is used in writing C# code, so everyone is comfortable in using this tool. And this is the reason why I love this great tool so much. Kudos to Matthias Koch for it!

As you might guess, I'm using Nuke scripts to setup everything else which usually has to be done manually. I'm not going to write a tutorial for nuke at this place, but just as much as need to get you a picture of it.

A nuke script can be initialized with following commands:

dotnet tool install Nuke.GlobalTool --global
nuke :setup

This will guide you through a wizard and sets up a Nuke project inclusive some startup scripts for you. Than you can start to implement your automation script with it.

class Build : NukeBuild
    public static int Main() => Execute<SetupDevEnv>();

    Target SetupDevEnv => _ => _
        .Executes(() =>
             // This one usually has no implementation, but calls other targets which are doing their jobs

    Target CreateOrUpgradeDatabase => _ => _
        .Executes(() =>
            // Create or upgrade databasae implementation

And afterwards you can execute the script with following command: --target SetupDevEnv

And with that your dev env is ready and you can start hacking.

Final dev env setup steps

With all this in place, your dev env setup will be reduced to the following steps.

Dev Env Setup Instruction

Required software:

  • GIT
  • Docker Desktop
  • DotNet Core SDK
  • NodeJS
  • Rider or Visual Studio

Clone the repo:

git clone <repor-url> my-app

Startup infrastructure:

docker-compose -f -p my-app up

Setup dev env: --target SetupDevEnv

Great, that's it! You can open your IDE and hit F5.