dockgen 0.5.0

dotnet tool install --global dockgen --version 0.5.0
                    
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
                    
if you are setting up this repo
dotnet tool install --local dockgen --version 0.5.0
                    
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=dockgen&version=0.5.0
                    
nuke :add-package dockgen --version 0.5.0
                    

Bugs Reliability Rating Technical Debt Maintainability Rating Vulnerabilities

dock-gen

dock-gen is a simple .NET tool designed to generate Dockerfiles for one or multiple projects in a solution based on project dependencies.

Please note, dock-gen is still in its early stages, some features may not be stable.

Installation

To install dock-gen, you can use the dotnet tool install command:

  1. global installation:
dotnet tool install --global dockgen
  1. local installation: (optional) if you don't have a manifest file for your project, create one:
dotnet new tool-manifest

Add the tool to the manifest file:

dotnet tool install dockgen

Usage

Command reference

Command Aliases Description
generate g, gen Generate Dockerfiles for eligible projects discovered from --solution or --directory, or for a single project specified via --project.
update u, upd Update Dockerfiles for eligible projects discovered from --solution or --directory, or for a single project specified via --project. By default rewrites the whole file; with --only-references updates only the project-reference COPY section inside the build stage and leaves the rest untouched.

Global options

Option Aliases Type Default Description
--verbose --debug, --trace bool false Enable detailed logging (includes trace output). Use before the command name.

generate (g, gen)

Option Aliases Type Default Description
--directory -d string Discover projects under a directory (recursively) and generate Dockerfiles for eligible projects.
--solution -s string Discover projects in a solution and generate Dockerfiles for eligible projects.
--project -p string Generate a Dockerfile for a single project.
--analyzer -a string FastAnalyzer Analyzer to use: FastAnalyzer, DesignBuildTimeAnalyzer, SimpleAnalyzer.
--multi-arch bool true Generate a multi-arch Dockerfile (FROM --platform=$BUILDPLATFORM).

If none of --solution, --project, or --directory are provided, dock-gen will try to locate all projects inside the current directory recursively.

update (u, upd)

Option Aliases Type Default Description
--directory -d string Discover projects under a directory (recursively) and update Dockerfiles for eligible projects.
--solution -s string Discover projects in a solution and update Dockerfiles for eligible projects.
--project -p string Update the Dockerfile for a single project.
--analyzer -a string FastAnalyzer Analyzer to use: FastAnalyzer, DesignBuildTimeAnalyzer, SimpleAnalyzer.
--multi-arch bool true Generate a multi-arch Dockerfile (FROM --platform=$BUILDPLATFORM).
--only-references bool false Update only the project-reference COPY section in the existing Dockerfile.

If none of --solution, --project, or --directory are provided, dock-gen will try to locate all projects inside the current directory recursively.

Examples

Generate Dockerfiles for all projects in a solution:

dotnet dockgen generate --solution .\\Solution.sln

Generate Dockerfiles (using alias):

dotnet dockgen g --solution .\\Solution.sln

Update Dockerfiles for all projects in a solution:

dotnet dockgen update --solution .\\Solution.sln

Update only the project reference COPY section in existing Dockerfiles:

dotnet dockgen update --solution .\\Solution.sln --only-references

Enable detailed logging (any of these is equivalent):

dotnet dockgen --verbose g --solution .\\Solution.sln

Use a non-default analyzer:

dotnet dockgen generate --analyzer DesignBuildTimeAnalyzer --solution .\\Solution.sln

Notes and limitations

  • FastAnalyzer does not run MSBuild. It can’t evaluate all conditional logic, custom tasks, or target execution. If your repo relies heavily on dynamic MSBuild evaluation, prefer DesignBuildTimeAnalyzer.

Features

  • Generate Dockerfile: Generate a Dockerfile for a single or multiple projects at once
  • Multi-Stage Build: Generate a multi-stage Dockerfile for a project
  • Central Package/Build Management: dock-gen supports CPM/CBM in your project

Supported properties

Description for MSBuild properties can be found here: Official .NET docs

Property Description MSBuild Property Custom Property Default Value
ContainerBaseImage* ✔ yes ✘ no mcr.microsoft.com:443/dotnet/aspnet:10.0
ContainerRegistry Registry of the base image ✔ yes ✘ no mcr.microsoft.com
ContainerRepository Repository of the base image ✔ yes ✘ no dotnet/aspnet
ContainerFamily Family of the base image ✔ yes ✘ no
ContainerImageTag Tag of the base image ✔ yes ✘ no 10.0
ContainerBasePort Port of the base image ✘ no ✔ yes 443
ContainerPort Port(s) to expose in Dockerfile ✔ yes ✘ no
ContainerBuildImage Build image for the project ✘ no ✔ yes mcr.microsoft.com:443/dotnet/sdk:10.0
ContainerBuildRegistry Registry of the build image ✘ no ✔ yes mcr.microsoft.com
ContainerBuildRepository Repository of the build image ✘ no ✔ yes dotnet/sdk
ContainerBuildFamily Family of the build image ✘ no ✔ yes
ContainerBuildImageTag Tag of the build image ✘ no ✔ yes 10.0
ContainerBuildPort Port of the build image ✘ no ✔ yes 443

Roadmap

  • Support more advanced Dockerfile customizations

Contributing

We welcome contributions to dock-gen!

License

dock-gen is open source software licensed under the MIT. See the LICENSE file for more details.

Contact

If you have any questions or feedback, please feel free to create an issue.

Troubleshooting

  • Dockerfile not generated

    • Only executable projects (OutputType=Exe) get Dockerfiles. Library projects are skipped.
    • Test projects are skipped.
  • Dependency graph looks incomplete

    • Try --analyzer DesignBuildTimeAnalyzer to use MSBuild design-time evaluation.

Acknowledgements

This project makes use of the following open source projects:

  • Buildalyzer: A utility for performing design-time builds of .NET projects to obtain information such as package references and compiler flags.
  • Serilog: Simple .NET logging with fully-structured events.
  • .NET: .NET platform
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last Updated
0.5.0 102 1/12/2026
0.4.1 147 7/5/2025
0.4.0 141 7/5/2025
0.3.0 230 10/21/2024
0.2.1 237 5/12/2024
0.2.0 160 5/3/2024
0.1.0 200 4/30/2024