Developing .NET applications without installing .NET SDK
I recently developed a small .NET application. I considered installing the .NET SDK on my laptop (on which I were to develop the .NET application), but was unsure of which version I would need, and how I would potentially downgrade the SDK version if needed.
Instead of installing the SDK on my laptop, I decided to run the SDK inside a Docker container. This way I could easily switch between SDK versions if needed, as all I’d have to do is spin up another Docker container with a different version of the SDK installed.
I created a file Dockerfile.runtime with this content that I would use for my runtime environment:
1 2 |
FROM microsoft/dotnet-framework:4.7.2-sdk AS build WORKDIR /app |
Building the docker container the usual way:
1 |
docker build --pull -t runtime -f .\Dockerfile.runtime . |
Now that my image was build containing the SDK I needed, I was ready to run my application:
1 |
docker run --rm -v C:\Users\kenneho\projects\myproject\myapp:c:\app runtime dotnet run |