A DNN module that ships a class library and browser assets is installed from one zip, so the pipeline's job is to produce that zip and keep it somewhere durable. Putting it on a GitLab Release tagged with the version already in the .dnn manifest gives installers and the changelog one place to look, and makes the manifest the only place a version is typed.
The module and its install zip
The example project is example/carousel-react, laid out in three parts:
| Path | What it holds |
|---|---|
src/CarouselReact/ |
CarouselReact.csproj, View.ascx and its code-behind, built into Example.CarouselReact.dll |
src/web/ |
The Vite and React app, whose vite.config.js sets build.outDir to ../CarouselReact/Resources |
install/CarouselReact.dnn |
The DNN manifest, whose <package version="01.00.00"> is the module's version |
The assembly targets net48, because DNN 10 is built for it: the DotNetNuke.Core 10.4.1 NuGet package ships only lib/net48. Vite writes carousel.js, carousel.css and the files from public/ into Resources, so a release needs both the compiled DLL and the Vite output, and the folder stays out of Git because the build creates it.
The project file that writes the zip
src/CarouselReact/CarouselReact.csproj compiles the module and, after every build that does not opt out, stages the files DNN installs and zips them:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net48</TargetFramework>
<AssemblyName>Example.CarouselReact</AssemblyName>
<RootNamespace>Example.CarouselReact</RootNamespace>
<DnnManifest>$(MSBuildProjectDirectory)\..\..\install\CarouselReact.dnn</DnnManifest>
</PropertyGroup>
<ItemGroup>
<Reference Include="DotNetNuke">
<HintPath>$(DnnLib)\DotNetNuke.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="System.Web" />
</ItemGroup>
<Target Name="CreateDnnInstaller" AfterTargets="Build" Condition="'$(SkipDnnInstaller)' != 'true'">
<XmlPeek XmlInputPath="$(DnnManifest)" Query="/dotnetnuke/packages/package/@version">
<Output TaskParameter="Result" PropertyName="DnnPackageVersion" />
</XmlPeek>
<Error Condition="!Exists('Resources\carousel.js')" Text="Resources\carousel.js is missing. Run npm run build in src\web first." />
<PropertyGroup>
<DnnStageDir>$(IntermediateOutputPath)dnn-package\</DnnStageDir>
<DnnPackageZip>$(OutputPath)$(AssemblyName)_$(DnnPackageVersion)_Install.zip</DnnPackageZip>
</PropertyGroup>
<ItemGroup>
<DnnResource Include="Resources\**\*" Exclude="Resources\index.html" />
</ItemGroup>
<RemoveDir Directories="$(DnnStageDir)" />
<Copy SourceFiles="$(TargetPath)" DestinationFolder="$(DnnStageDir)bin" />
<Copy SourceFiles="$(DnnManifest);View.ascx" DestinationFolder="$(DnnStageDir)" />
<Copy SourceFiles="@(DnnResource)" DestinationFiles="@(DnnResource->'$(DnnStageDir)Resources\%(RecursiveDir)%(Filename)%(Extension)')" />
<ZipDirectory SourceDirectory="$(DnnStageDir)" DestinationFile="$(DnnPackageZip)" Overwrite="true" />
<Message Importance="high" Text="DNN install zip: $(DnnPackageZip)" />
</Target>
</Project>
XmlPeek reads the version attribute straight from the manifest, so the zip's name follows the manifest without a second copy of the version in the project file. A project that keeps its own DnnPackageVersion property drifts the first time someone bumps the manifest and not the property, and the zip then carries the old version in its name.
The Error task stops the build with a message that names the fix when the Vite output is missing, instead of producing a zip with no script in it. The target does not run npm itself. The pipeline below builds the front end once and hands Resources to the job that packages it, and a target that ran npm install would repeat that work in every job that compiles the project. Locally, run npm run build in src/web before building in Visual Studio.
The rest of the target stages bin/Example.CarouselReact.dll, the manifest, View.ascx and everything in Resources except the index.html Vite writes for its dev page, then zips the stage into bin/Release/net48/Example.CarouselReact_<version>_Install.zip. Building with -p:SkipDnnInstaller=true compiles without packaging, which is what the build and test jobs use.
DNN assemblies from the runner
The module compiles against DNN 10's DotNetNuke.dll, which stays out of the repository. Instead, the Windows runner keeps a copy of the DNN 10 assemblies in a folder, and a project CI/CD variable named DNN_LIB holds that folder's path. The HintPath above reads it as $(DnnLib), so every dotnet command in the pipeline passes -p:DnnLib=$env:DNN_LIB.
<Private>false</Private> keeps DotNetNuke.dll out of the build output, because the DNN site already has it and the install zip should not carry a second copy. In the run below, bin held only Example.CarouselReact.dll and its .pdb.
Build and test on the Windows runner
The first part of .gitlab-ci.yml sends every job to the Windows runner and builds and tests the module:
stages: [build, test, package]
default:
tags: [windows]
build:
stage: build
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
script:
- npm ci --prefix src/web
- npm run build --prefix src/web
- dotnet build src/CarouselReact/CarouselReact.csproj -c Release "-p:DnnLib=$env:DNN_LIB" -p:SkipDnnInstaller=true
artifacts:
paths: [src/CarouselReact/Resources/]
expire_in: 1 day
test:
stage: test
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
script:
- |
$projects = Get-ChildItem -Path src -Recurse -Filter "*Tests*.csproj"
foreach ($project in $projects) {
dotnet test $project.FullName -c Release "-p:DnnLib=$env:DNN_LIB" -p:SkipDnnInstaller=true
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
}
default: tags: [windows] applies to all three jobs, because the module is a .NET Framework 4.8 WebForms library built on the same Windows runner pool as A Windows Runner for IIS Projects, and the rules follow that article for the same reason. In build, npm ci and npm run build write the Vite files into src/CarouselReact/Resources, and dotnet build compiles the DLL with the installer target skipped. The artifacts block hands Resources to the later jobs for one day, since each job starts from a clean checkout. A job with no needs downloads the artifacts of every job in earlier stages, so package gets them without asking.
test looks under src for any project whose name contains Tests and runs dotnet test on each one, stopping at the first failure. A module with no test project finds nothing, so the loop never runs and the job passes.
The package job
The package job closes the same .gitlab-ci.yml and runs only on the default branch:
package:
stage: package
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
script:
- |
$ErrorActionPreference = "Stop"
[xml]$manifest = Get-Content -LiteralPath "install/CarouselReact.dnn"
$version = $manifest.dotnetnuke.packages.package.version
$api = "$env:CI_API_V4_URL/projects/$env:CI_PROJECT_ID"
$status = curl.exe --silent --output NUL --write-out "%{http_code}" --header "JOB-TOKEN: $env:CI_JOB_TOKEN" "$api/releases/$version"
if ($status -eq "200") {
Write-Host "Release $version exists. Bump the version in install/CarouselReact.dnn to ship again."
exit 0
}
if ($status -ne "404") { throw "The release check for $version returned HTTP $status." }
dotnet build src/CarouselReact/CarouselReact.csproj -c Release "-p:DnnLib=$env:DNN_LIB"
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
$zipName = "Example.CarouselReact_${version}_Install.zip"
$zipPath = "src/CarouselReact/bin/Release/net48/$zipName"
if (-not (Test-Path -LiteralPath $zipPath)) { throw "CreateDnnInstaller did not write $zipPath" }
$packageUrl = "$api/packages/generic/carousel-react/$version/$zipName"
curl.exe --fail --silent --show-error --header "JOB-TOKEN: $env:CI_JOB_TOKEN" --upload-file $zipPath $packageUrl
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
$release = @{
name = $version
tag_name = $version
ref = $env:CI_COMMIT_SHA
description = "Install zip for $version, built from $env:CI_COMMIT_SHORT_SHA."
assets = @{ links = @(@{ name = $zipName; url = $packageUrl; link_type = "package" }) }
} | ConvertTo-Json -Depth 5
Invoke-RestMethod -Method Post -Uri "$api/releases" -ContentType "application/json" -Headers @{ "JOB-TOKEN" = $env:CI_JOB_TOKEN } -Body $release
The script starts from the manifest. [xml] parses install/CarouselReact.dnn, and $version is the same version attribute the project file reads, which becomes the package version, the tag and the Release name. $ErrorActionPreference = "Stop" makes any failing PowerShell command end the job, while each native command is checked through $LASTEXITCODE, because PowerShell does not stop on a native exit code by itself. curl.exe is spelled out because in Windows PowerShell 5.1 curl is an alias for Invoke-WebRequest.
The first curl.exe call asks the Releases API for a release with that tag and keeps only the HTTP status. A 200 means this version has already shipped, so the job prints why and exits successfully before it builds anything, which is how a rerun avoids a duplicate tag. A 404 is the only other answer that means "go ahead". Anything else, such as a 401 from a token the project refuses or 000 when the API cannot be reached, says nothing about whether the release exists, so the job throws before it builds or uploads.
For a new version, dotnet build runs without -p:SkipDnnInstaller=true, so CreateDnnInstaller writes the zip, and the script checks for it at the path the target writes to. The check catches a renamed target, or a manifest whose version the target read differently, before anything is uploaded.
The second curl.exe call uploads the zip to the Generic Package Registry. --upload-file sends an HTTP PUT to packages/generic/carousel-react/$version/$zipName, and --fail turns an HTTP error into a non-zero exit code. GitLab 19.6 checks the version against the same pattern it uses for Maven, \A(?!.*\.\.)[\w+.-]+\z, so a DNN version with leading zeros such as 01.00.00 is accepted as it is.
Last, Invoke-RestMethod posts to the Releases API: ref creates the tag at this commit, and the single entry in assets.links points at the package URL with link_type set to package. -Depth 5 is not decoration. ConvertTo-Json stops at depth 2 by default, and in Windows PowerShell 5.1 the default turned the link into the string "System.Collections.Hashtable" inside links, in place of the object with name, url and link_type that the Releases API expects.
All three API calls authenticate with CI_JOB_TOKEN in the JOB-TOKEN header. GitLab's job token documentation lists the Releases API and the Package Registry among the endpoints a job token can call, and the token acts with the permissions of the user whose push started the pipeline, so that user needs a role that can publish packages and create releases on the project, which is Developer or higher.
What a run showed
The project file and the package script above ran unchanged on Windows with the .NET 10 SDK, against DotNetNuke.dll from the DotNetNuke.Core 10.4.1 package, and the package script ran in Windows PowerShell 5.1 against a local stand-in for the three GitLab endpoints. GitLab 19.6.1's CI lint accepted the whole .gitlab-ci.yml.
| Case | Result |
|---|---|
dotnet build -p:SkipDnnInstaller=true |
The DLL alone; no zip, no check for Resources |
A build with the installer before npm run build |
Resources\carousel.js is missing. Run npm run build in src\web first. |
| A build with the installer after it | Example.CarouselReact_01.00.00_Install.zip holding CarouselReact.dnn, View.ascx, bin/Example.CarouselReact.dll and the Resources files, without index.html or DotNetNuke.dll |
The manifest bumped to 01.00.01, project file untouched |
Example.CarouselReact_01.00.01_Install.zip |
| First package run | Release check 404, one PUT of the zip, one POST with the link; exit 0 |
| The same commit again | "Release 01.00.00 exists…"; no build, no upload; exit 0 |
| A token the API refuses | "The release check for 01.00.01 returned HTTP 401."; nothing built or uploaded; exit 1 |
The release POST refused with 403 |
The zip already uploaded, Invoke-RestMethod threw, exit 1 |
ConvertTo-Json without -Depth |
"links":["System.Collections.Hashtable"] |
| A missing release on the real GitLab | 404 with {"message":"404 Not Found"} |
The refused POST is the one failure that leaves something behind. The package is in the registry and no release points at it, so a retry finds no release, uploads the zip again and creates the release. GitLab allows duplicate files in a generic package by default and adds the second upload to the same package version, so the retry succeeds and the version lists two copies of the zip. A project that turns off duplicates for generic packages has to delete that package version before the retry.
What this run did not cover is a Windows runner executing the pipeline against a real project, with a real job token: the API calls went to a stand-in that answered the way GitLab's documentation and its 404 response do.
Artifacts and the Release asset
Job artifacts carry the Vite output from build to package and expire after a day, because they exist only for that hand-off. The durable download is the Release asset, which points at the package in the registry and stays as long as the package does.
Each new manifest version that reaches the default branch therefore ends with one install zip in the Generic Package Registry and a Release, named for that version, that links to it. A push that keeps the old version stops at the release check, so shipping again starts with bumping the version in the .dnn manifest, the one place the version is written.