Introduction
Shipping a .NET application should be a non-event. Yet many teams still release by hand: bump a version in a .csproj, build on a laptop, write release notes from memory and copy files to a server. Every manual step is a chance to ship the wrong build or skip a test.
Release automation removes that risk. With GitLab CI/CD, every merge and tag follows the same repeatable path: build, test, scan, version, package, publish, release and deploy.
The timing matters. .NET 11 shipped on November 10, 2026 as a Standard Term Support release, and the same day .NET 8 and .NET 9 reached end of support. GitLab 19.x, meanwhile, added a native Secrets Manager, CI/CD Catalog analytics and SBOM-based dependency scanning. This guide shows how to build a modern .NET release pipeline on GitLab, with a complete .gitlab-ci.yml, versioning, supply chain security, deployment patterns and FAQs.
What release automation means for .NET teams
Release automation turns a code change into a versioned, tested, signed and deployable artifact with no manual steps. CI proves the code compiles and passes tests; release automation also decides the version, writes release notes, publishes NuGet packages or container images, creates a GitLab Release and promotes the build through environments.
Why it pays off
- Faster lead time. Hours of manual work become minutes of pipeline time, improving your DORA metrics.
- Consistency. Every build uses the same SDK image, so "works on my machine" disappears.
- Lower risk. Small, frequent releases are easier to test and roll back.
- Traceability. Every artifact links to a commit, pipeline, merge request and approver.
- Built-in security. Scans, SBOMs and signing run on every release, not once a quarter.
New to the concepts? Start with what DevOps is or our guide to choosing a DevOps service provider.
The modern .NET and GitLab toolchain in 2026
The tools have changed a lot in the past two years. Pick a current baseline before you write any YAML.
| Area | Recommended in 2026 | Why it matters |
|---|---|---|
| .NET runtime | .NET 10 LTS (supported to Nov 2028) or .NET 11 STS | .NET 8 and 9 are out of support since Nov 10, 2026 |
| Build images | mcr.microsoft.com/dotnet/sdk:10.0 from the Microsoft Artifact Registry | Pinned, patched SDK on every runner |
| Containers | dotnet publish /t:PublishContainer (SDK container publishing) | Builds OCI images without a Dockerfile |
| Pipeline reuse | GitLab CI/CD components and the CI/CD Catalog with typed spec:inputs | One versioned template for every .NET repo |
| Releases | release keyword with the GitLab CLI (glab) | release-cli was deprecated in GitLab 18.0 |
| Secrets | GitLab Secrets Manager (beta), Vault, or cloud key vaults via OIDC id_tokens | Job-scoped secrets, no long-lived keys |
| Security | SAST, Dependency Scanning with SBOM, Secret Detection, container scanning | Supply chain evidence for every build |
| AI assistance | GitLab Duo, including the CI Expert Agent and Fix CI/CD Pipeline Flow | Faster pipeline authoring and debugging |
Note the release change: since GitLab 18.0 the release keyword runs through glab, and release-cli is in maintenance mode, so use the registry.gitlab.com/gitlab-org/cli:latest image for release jobs. GitLab 19.0's Components Analytics also shows which repositories use each version of a shared .NET component before you ship a breaking change.
Designing the release pipeline
A good .NET release pipeline has two lanes. Merge requests and the default branch get fast feedback: build, test and scan. Version tags such as v2.4.0 trigger the full release path: package, publish, create a GitLab Release and deploy.
| Stage | What runs | When |
|---|---|---|
| build | dotnet restore --locked-mode, dotnet build | Every pipeline |
| test | dotnet test with JUnit and Cobertura reports | Every pipeline |
| security | SAST, Dependency Scanning (SBOM), Secret Detection | Every pipeline |
| package | dotnet pack to NuGet, PublishContainer to the registry | Tags only |
| release | Release notes plus a GitLab Release via glab | Tags only |
| deploy | Staging automatically, production after approval | Tags only |
A complete .gitlab-ci.yml for .NET 10
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- if: $CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+$/
stages: [build, test, security, package, release, deploy]
include:
- template: Jobs/SAST.gitlab-ci.yml
- template: Jobs/Dependency-Scanning.gitlab-ci.yml
- template: Jobs/Secret-Detection.gitlab-ci.yml
variables:
CONFIGURATION: Release
NUGET_PACKAGES: $CI_PROJECT_DIR/.nuget/packages
DOTNET_CLI_TELEMETRY_OPTOUT: "1"
DOTNET_NOLOGO: "1"
default:
image: mcr.microsoft.com/dotnet/sdk:10.0
cache:
key:
files: [Directory.Packages.props]
paths: [.nuget/packages]
before_script:
- |
if [ -n "$CI_COMMIT_TAG" ]; then export APP_VERSION="${CI_COMMIT_TAG#v}";
else export APP_VERSION="0.0.0-ci.${CI_PIPELINE_IID}"; fi
build:
stage: build
script:
- dotnet restore --locked-mode
- dotnet build --no-restore -c $CONFIGURATION -p:Version=$APP_VERSION
test:
stage: test
script:
- dotnet test -c $CONFIGURATION
--logger "junit;LogFilePath=TestResults/{assembly}.xml"
--collect:"XPlat Code Coverage"
artifacts:
when: always
reports:
junit: "**/TestResults/*.xml"
coverage_report:
coverage_format: cobertura
path: "**/coverage.cobertura.xml"
publish-nuget:
stage: package
rules: [{ if: $CI_COMMIT_TAG }]
script:
- dotnet pack -c $CONFIGURATION -p:Version=$APP_VERSION -o out
- dotnet nuget add source "$CI_API_V4_URL/projects/$CI_PROJECT_ID/packages/nuget/index.json"
--name gitlab --username gitlab-ci-token --password $CI_JOB_TOKEN
--store-password-in-clear-text
- dotnet nuget push "out/*.nupkg" --source gitlab
publish-image:
stage: package
rules: [{ if: $CI_COMMIT_TAG }]
variables:
DOTNET_CONTAINER_REGISTRY_UNAME: $CI_REGISTRY_USER
DOTNET_CONTAINER_REGISTRY_PWORD: $CI_REGISTRY_PASSWORD
script:
- dotnet publish src/Api/Api.csproj -c $CONFIGURATION /t:PublishContainer
-p:ContainerRegistry=$CI_REGISTRY
-p:ContainerRepository=$CI_PROJECT_PATH/api
-p:ContainerImageTag=$APP_VERSION
release-notes:
stage: release
image: alpine:3.22
rules: [{ if: $CI_COMMIT_TAG }]
before_script: []
script:
- apk add --no-cache curl jq
- curl -sf --header "PRIVATE-TOKEN: $RELEASE_TOKEN"
"$CI_API_V4_URL/projects/$CI_PROJECT_ID/repository/changelog?version=${CI_COMMIT_TAG#v}"
| jq -r .notes > release_notes.md
artifacts:
paths: [release_notes.md]
create-release:
stage: release
image: registry.gitlab.com/gitlab-org/cli:latest
needs: [release-notes]
rules: [{ if: $CI_COMMIT_TAG }]
before_script: []
script:
- echo "Creating GitLab Release $CI_COMMIT_TAG"
release:
tag_name: $CI_COMMIT_TAG
name: "Release $CI_COMMIT_TAG"
description: ./release_notes.md
.deploy:
stage: deploy
image:
name: alpine/helm:3.17.0
entrypoint: [""]
rules: [{ if: $CI_COMMIT_TAG }]
before_script: []
script:
- helm upgrade --install api ./charts/api
--kube-context "$KUBE_CONTEXT" --namespace "$NAMESPACE"
--set image.tag="${CI_COMMIT_TAG#v}" --wait --atomic
deploy-staging:
extends: .deploy
variables: { NAMESPACE: staging, KUBE_CONTEXT: "my-group/agents:staging" }
environment: { name: staging }
resource_group: staging
deploy-production:
extends: .deploy
needs: [deploy-staging]
when: manual
variables: { NAMESPACE: production, KUBE_CONTEXT: "my-group/agents:production" }
environment: { name: production }
resource_group: productionHow the key pieces work
- Locked restores.
--locked-modefails the build ifpackages.lock.jsondrifts (enableRestorePackagesWithLockFileinDirectory.Build.props). - Test reports. The
JunitXml.TestLoggerpackage and Coverlet's Cobertura output show results and coverage inside merge requests. - No stored credentials.
CI_JOB_TOKENauthenticates to the GitLab NuGet registry, andPublishContainerpushes to the GitLab Container Registry without a Dockerfile. - Safe deploys.
resource_groupblocks concurrent deployments, and Helm's--atomicflag rolls back if pods fail to become ready.
Once this works for one service, move it into a versioned CI/CD component so every .NET repository includes the same tested pipeline with a single line. Our CI/CD consulting team builds these reusable templates and golden paths for multi-repo .NET estates.
Versioning, changelogs and GitLab Releases
A release is only as trustworthy as its version number. Follow Semantic Versioning (MAJOR.MINOR.PATCH) and let Git, not a person, decide the number.
Choosing a versioning strategy
| Approach | How it works | Best for |
|---|---|---|
| Tag-driven | Pipeline reads v1.4.2 from CI_COMMIT_TAG (as in the example above) | Small teams, simple apps |
| MinVer | Calculates the version from the latest tag at build time | Libraries and NuGet packages |
| GitVersion | Derives versions from branch names and commit history | GitFlow and multi-branch workflows |
| Nerdbank.GitVersioning | Version stored in version.json, height from commits | Microsoft-style repos, monorepos |
| Conventional Commits + semantic-release | Commit messages decide major, minor or patch bumps | Fully automated tagging |
Whichever you pick, pass the result to MSBuild once (-p:Version=...) so assemblies, NuGet packages and container tags always match.
Generating release notes automatically
Add a Changelog: added or Changelog: fixed trailer to commit messages, and GitLab's changelog API groups those commits by category for each version. The release-notes job above calls it, so every release documents itself.
Creating the GitLab Release
The release keyword creates a GitLab Release tied to the tag, with notes, asset links (package, image, SBOM) and release evidence that helps with SOC 2 and ISO 27001 audits. Protect v* tags so only maintainers or an approved bot can trigger a production release.
Security, compliance and software supply chain
Attackers now target build systems as often as applications, so a release pipeline must prove what went into each build. Build these controls in from day one:
- Shift-left scanning. GitLab SAST, Dependency Scanning and Secret Detection check C# code and NuGet packages on every merge request.
dotnet list package --vulnerable --include-transitiveadds a fast CVE gate. - SBOMs. Attach a CycloneDX SBOM from GitLab or the CycloneDX .NET tool to every release.
- Signing. Sign images keylessly with Sigstore Cosign using GitLab OIDC
id_tokens, and work toward SLSA build provenance. - No long-lived secrets. Use GitLab Secrets Manager, Vault or cloud key vaults over OIDC, and mark leftover variables masked, hidden and protected.
- Policy as code. Pipeline execution policies enforce scans in every project. See our post on policy as code with Open Policy Agent.
For regulated industries, these steps map directly to the OWASP Top 10 CI/CD Security Risks. If you need help wiring them together, our DevSecOps consulting and cloud security teams do this every week.
Deployment strategies: environments, approvals and rollbacks
The deploy stage is where release automation earns its keep. GitLab gives you several building blocks:
- Environments record which version runs where, with full deployment history.
- Protected environments with deployment approvals and
when: manualgive you an auditable change gate. resource_groupprevents two pipelines deploying to the same environment at once.- Rollback is a re-run of the last successful deployment job.
Choosing a deployment target
| Target | How the pipeline deploys | Notes |
|---|---|---|
| Kubernetes (EKS, AKS, GKE) | GitLab agent for Kubernetes with Helm, or GitOps with Flux or Argo CD | Best for microservices and scale |
| Azure App Service | az webapp deploy using OIDC federated credentials | Simple for ASP.NET Core web apps |
| AWS ECS or Lambda | AWS CLI or CDK with OIDC role assumption | No stored AWS keys |
| Windows VMs and IIS | Windows runner with PowerShell and Web Deploy | Common for legacy .NET Framework apps |
For Kubernetes, GitOps scales best: the pipeline updates an image tag and Argo CD or Flux syncs the cluster, ideally with canary or blue-green rollouts. Our GitOps consulting, Helm consulting and managed Kubernetes services cover this end to end, and our zero-downtime Kubernetes upgrade guide applies the same thinking to the platform.
Close the loop by tagging dashboards with each release version and alerting on regressions. See our monitoring and observability and 24x7 SRE services.
Best practices and common pitfalls
Best practices
- Pin your SDK with
global.jsonand a fixed image tag, and let Renovate or Dependabot propose updates. - Build once, deploy many. Promote the same artifact; never rebuild per environment.
- Keep pipelines fast with NuGet caching,
needs:andparallel:. Aim for merge request pipelines under 10 minutes. - Version pipeline code as a CI/CD component and review it like product code.
- Use AI with review. GitLab Duo's CI Expert Agent can draft jobs and explain failures; humans approve production changes.
Common pitfalls
- Secrets in YAML or logs. Use masked, protected variables or a secrets manager.
- Unprotected
v*tags, which let anyone who can push a tag ship to production. - Floating
latestimages, which make builds unreproducible. - Unsupported runtimes. .NET 8 and 9 get no patches after November 10, 2026. Multi-target
net10.0andnet11.0in the pipeline, then switch.
If your pipelines also need to scale across many teams, consider a platform engineering approach with golden paths that bake these practices into every new .NET service.
Conclusion
Release automation turns .NET delivery into a predictable, auditable routine: version from Git, test every change, publish packages and images, create GitLab Releases with evidence, and promote builds through protected environments with one-click rollback.
The end of support for .NET 8 and .NET 9 makes 2026 the right moment to modernise. Start with the pipeline in this guide, move it into a reusable CI/CD component, then layer on SBOMs, signing and GitOps as your maturity grows.
Ready to automate your .NET releases? SquareOps is an AWS Advanced Tier Services Partner with deep GitLab CI/CD, Kubernetes and DevSecOps experience. Explore our DevOps services, read our case studies, or book a free architecture review with a senior engineer.