Posted by Anuraj on Thursday, December 29, 2016 Reading time :1 minute
This post is about enabling Continuous Integration of .NET projects in Gitlab. Majority of GitLab’s CI examples are around Open Source technologies. In this post I will explain about implementing CI in ASP.NET and ASP.NET Core projects with Gitlab.
In GitLab CI, Runners run your yaml. A runner is an isolated (virtual) machine that picks up builds through the coordinator API of GitLab CI. So for building ASP.NET you need to first create a runner on your Windows system. You can find the install and configuration details on GitLab wiki.
Once installation is proper, you can find the Gitlab runner in your services.
You can find the runner in the project runners section.
Now for enabling the continuous integration, need to add
.gitlab-ci.yml file. Here is a sample .gitlab-ci.yml, which will restore the packages and build the solution.
Make sure you have nuget.exe is installed on C:\Nuget folder. And you have MSBuild.exe (VS2015) installed on Program Files folder. Once you commit any changes, the build will be triggered and here is the details of completed build.
You can include the MSTest or NUnit as part of the yml file.
You can use similar approach for ASP.NET Core project as well. GitLab supports Docker based CI as well. So here is the .gitlab-ci.yml file for building ASP.NET Core projects.
This file will download the
microsoft/dotnet image, before executing the build script, Gitlab will execute
dotnet restore command, and in the build stage, Gitlab will execute the
dotnet build command.
Happy Programming :)