ASP.NET Core · · 1 min read

How to (temporarily) disable Docker support in your .NET Core project

This post describes how docker support can be (temporarily) disabled with

How to (temporarily) disable Docker support in your .NET Core project

Introduction

This is going to be a short post ⏲. Usually, I prefer to go through the initial development process of my ASP.NET Core applications without Docker support. For a simple reason - it allows for quicker startup times of the application in debug mode.

However, later in time, I often would like to containerize it back again. So how can we switch back and forth between a Docker and a Non-Docker debug configuration?

The solution is a simple and short one. Let's see how it's done!

Solution

From within your projects folder find the <projectname>.csproj.user file and change the following line

<ActiveDebugProfile>Docker</ActiveDebugProfile>

to this

<ActiveDebugProfile>Debug</ActiveDebugProfile>

In case you'd like to entirely drop Docker support, you can even delete the Dockerfile and <projectname>.csproj.user file from your project.

☝🏻 The solution is only applicable to projects created with Visual Studio. In case you are using JetBrains Rider, the project scaffolding process wont create the described file.

So with this tiny trick at hand, I create all my projects with Docker support and then disable it until I find the time is right to turn it back on.

Visual Studio 2022 project scaffolding dialogue & Docker support

Further reading

Docker container development tools documentation - Visual Studio (Windows)
Learn how to build and manage container-based apps and services. Get documentation, example code, tutorials, and more.

Read next