CI Pipeline for dotnet
- Dotnet has two frameworks
- dotnet framework: Runs only on windows
- dotnet core framework: Runs on any platform
- Dotnet while building the code has two configurations
- Debug: These are generally for developers where they can debug the code.
- Release: All of building generally from CI are going to be release builds
- dotnet projects have two files of intrest
- Using dotnet core we can build a sln or csproj
- dotnet uses nuget packages to get dependencies.
- Refer Here for the dotnet project which we will be building
- to build dotnet core we need dotnet sdk and run the dotnet application we need dotnet runtime.
- The above project requires dotnet core 9 and aspdotnet core
- Installing dotnet 9.0 on ubuntu 24 Refer Here
sudo add-apt-repository ppa:dotnet/backports
sudo apt-get update && \
sudo apt-get install -y dotnet-sdk-9.0
dotnet --list-runtimes
- Dotnet builds create we get a folder with dll’s , exe’s and additional files such as json or xml files & generally we zip and share.
- Dotnet build commands
dotnet restore <path to sln or csproj>
dotnet build --configuration=Release <path to sln or csproj> --no-restore
dotnet test <path to test sln or csproj>
dotnet publish --configuration=Release <path to sln or csproj> --output <folder where you want the package>
- dotnet build
- dotnet test
-
Make changes in this workflow Refer Here to upload test results and zip and publish, As of now our package is present in published folder
-
Exercise:
- Upload test results
dotnet test --logger:"trx;LogFilePrefix=testResults" src/Tests/Nop.Tests/Nop.Tests.csproj in
- trx format
- html format
- junit format
- Zip (published) and upload the artifact, Artifact name should be
<repo-name>-<BuildNumber>.zip
Like this:
Like Loading...