Detection

migetpacks detects a .NET application when any of the following are present:
  • *.sln or *.slnx (solution files, root level)
  • global.json (root level)
  • *.csproj, *.fsproj, or *.vbproj (project files, up to 2 levels deep)

Version Detection

.NET SDK version is resolved in the following priority order: The TargetFramework value has the net prefix stripped (e.g., net8.0 becomes 8.0).

Build Process

migetpacks generates a multi-stage Dockerfile using the official .NET SDK and ASP.NET runtime images:

Source Code Cleanup

Since .NET is a compiled language, source code is completely removed from the runtime image after publishing: Only the bin/publish/ directory contents are kept in the final image.

.NET Tool Restore

If a .config/dotnet-tools.json is present, dotnet tool restore is run before the build to install any required .NET CLI tools.

Run Command

The default run command for .NET applications:
migetpacks detects the main DLL from the publish output. Override with RUN_COMMAND or a Procfile:

Runtime Configuration

The following environment variables are set for production:

Caching

Layer Caching

The .NET build uses NuGet cache mounts for dependency caching:

BUILD_CACHE_DIR

When BUILD_CACHE_DIR is set, NuGet packages are cached via BuildKit mount at:

DHI Support

Docker Hardened Images are supported for .NET builds.

DHI Notes

  • Build SDK images include the full .NET SDK for compilation.
  • Runtime images are based on ASP.NET Core distroless images (no shell, no apt-get).
  • The nonroot user is used instead of the miget user.
  • Suitable for web APIs and ASP.NET Core applications.

Example with DHI

Example

Monorepo with PROJECT_PATH

With custom build command