Table of Contents
1. Installation environment
2. Install the Jenkins plug-in
3. Jenkins Job Configuration
1. Restore NuGet package
2. Configure MSBuild compilation parameters
Home Backend Development C#.Net Tutorial Configuring a .NET continuous integration environment for Jenkins

Configuring a .NET continuous integration environment for Jenkins

Jan 24, 2017 pm 03:43 PM
.net

At the end of last year, thanks to the company's introduction of Jenkins, we took the first step in continuous integration. This article will not go into details on how to install Jenkins. The main focus is on configuring the .Net environment. In addition, this article is based on Jenkins installed in a Windows environment.

1. Installation environment

First we need to prepare several installation packages and install them on Windows:

.NET Framework 4.6.1 https://www.microsoft.com/zh-cn/download/details.aspx?id=49982
Microsoft Build Tools 2015 https://www.microsoft.com/zh-CN/download/details.aspx?id=48159
.NET Framework 4.6.1 Developer Pack https://www.microsoft.com/zh-CN/download/details.aspx?id=49978
NuGet x86 Commandline https://dist.nuget.org/index.html

The first one is of course the familiar .NET Framework running environment;

The second one is MSBuild. Although we usually use Visual Studio to compile and publish programs using the graphical interface, Visual Studio actually calls MSBuild to perform various operations. Therefore, if we want Jenkins to automatically compile code, we must also prepare a set for it. MSBuild.

The third package is the .NET Framework 4.6.1 Developer Pack, which was called Targeting Pack in the past and contains a bunch of assemblies. For example, early versions of Visual Studio 2013 did not have .NET Framework 4.6.1 when it was released. If you want it to support it, you need to install this developer package. If you do not install it, you will be prompted with an error that the System.Object and System.Attribute assemblies cannot be found when compiling the 4.6.1 program later. The 4.6.1 Developer Pack contains the contents of the 4.0, 4.5, and 4.6 Targeting Pack. Installing the 4.6.1 package does not require the installation of other versions of 4.0 packages. In addition, if you need Chinese support, you need to install the English version first, and then install the Chinese language pack.

The last item is the NuGet console program. Before compiling the program, you need to use NuGet to restore the package. This software does not need to be installed, just put it in a fixed location, such as D:\Tools\CI.

2. Install the Jenkins plug-in

Enter the Jenkins plug-in management page and install the MSBuild plug-in at: https://wiki.jenkins-ci. org/display/JENKINS/MSBuild+Plugin

After installation, enter the "Global Tool Configuration" interface:

Find the "MSBuild" column in the opened page, first click "MSBuild Installation", and then click the "Add MSBuild" button to configure the path of MSBuild.exe. Since I use 32-bit MSBuild, I can configure it like this:

Default installation path of MSBuild

32-bit C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe
64-bit C:\Program Files ( x86)\MSBuild\14.0\Bin\amd64\MSBuild.exe

Don’t forget to save after configuring.

3. Jenkins Job Configuration

After preparing the running environment and Jenkins plug-in, let’s create a new Job and give it a try. Our company uses Subversion, so I will download the code from SVN. Using repositories such as Git is also similar, so I will skip it here.

1. Restore NuGet package

We need to add an "Execute Windows batch command" step in the "Build" column to restore the NuGet package Restore

1 D:\tools\CI\nuget.exe restore .\YourSolutionName.sln
Copy after login

First, specify the path of nuget.exe, and then use the restore command to restore the package of the YourSolutionName.sln solution file in the current directory. You can modify it according to your actual situation.

2. Configure MSBuild compilation parameters

Still in the "Build" column, create a new "Build a Visual Studio project or solution using MSBuild" (generated using MSBuild VS project or solution) Steps

From top to bottom, in order

  • The selected MSBuild version

  • The path + file name of the target project or solution file

  • MSBuild parameters

Here we mainly talk about "Command Line Arguments" configuration, for more comprehensive MSBuild documentation, please refer to MSDN: https://msdn.microsoft.com/zh-CN/library/dd393574.aspx

I hope to generate a ASP.NET MVC project and publish it to the file system, mainly using:

  • /t:Rebuild Rebuild

  • /p:Configuration=Release Release generation mode

  • ##/p:VisualStudioVersion=14.0 Specify sub-toolset (https:/ /msdn.microsoft.com/zh-cn/library/bb383796.aspx) version, if not set, an error will be reported

  • /p:DeployOnBuild=True;PublishProfile=Testing-Environment -CI-publish Use the Testing-Environment-CI-publish.pubxml publishing file to publish the project

4. Supplement

[ Updated at 09:30 on January 24, 2017]

Sorry, I missed this when I posted the article last night. If you use MSBuild to compile the project according to the above configuration, you may encounter this error:

The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14" was not found .0\WebApplications\Microsoft.WebApplication.targets”

At this time, you only need to find a computer with Visual Studio 2015 installed and change C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio Copy all the contents in the \v14.0 directory to the directory of the Windows system where Jenkins is located, and then rebuild it.


There may be some content about Jenkins integrating xUnit.net unit testing and automatic release later, but I don’t know if it will be available before the year Can’t post it XD

I hope the article can be useful to everyone.

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1655
14
PHP Tutorial
1252
29
C# Tutorial
1226
24
Share several .NET open source AI and LLM related project frameworks Share several .NET open source AI and LLM related project frameworks May 06, 2024 pm 04:43 PM

The development of artificial intelligence (AI) technologies is in full swing today, and they have shown great potential and influence in various fields. Today Dayao will share with you 4 .NET open source AI model LLM related project frameworks, hoping to provide you with some reference. https://github.com/YSGStudyHards/DotNetGuide/blob/main/docs/DotNet/DotNetProjectPicks.mdSemanticKernelSemanticKernel is an open source software development kit (SDK) designed to integrate large language models (LLM) such as OpenAI, Azure

What are the employment prospects of C#? What are the employment prospects of C#? Oct 19, 2023 am 11:02 AM

Whether you are a beginner or an experienced professional, mastering C# will pave the way for your career.

.NET performance optimization technology for developers .NET performance optimization technology for developers Sep 12, 2023 am 10:43 AM

If you are a .NET developer, you must be aware of the importance of optimizing functionality and performance in delivering high-quality software. By making expert use of the provided resources and reducing website load times, you not only create a pleasant experience for your users but also reduce infrastructure costs.

Performance differences between Java framework and .NET framework Performance differences between Java framework and .NET framework Jun 03, 2024 am 09:19 AM

In terms of high-concurrency request processing, .NETASP.NETCoreWebAPI performs better than JavaSpringMVC. The reasons include: AOT early compilation, which reduces startup time; more refined memory management, where developers are responsible for allocating and releasing object memory.

C# .NET Interview Questions & Answers: Level Up Your Expertise C# .NET Interview Questions & Answers: Level Up Your Expertise Apr 07, 2025 am 12:01 AM

C#.NET interview questions and answers include basic knowledge, core concepts, and advanced usage. 1) Basic knowledge: C# is an object-oriented language developed by Microsoft and is mainly used in the .NET framework. 2) Core concepts: Delegation and events allow dynamic binding methods, and LINQ provides powerful query functions. 3) Advanced usage: Asynchronous programming improves responsiveness, and expression trees are used for dynamic code construction.

C# .NET: Exploring Core Concepts and Programming Fundamentals C# .NET: Exploring Core Concepts and Programming Fundamentals Apr 10, 2025 am 09:32 AM

C# is a modern, object-oriented programming language developed by Microsoft and as part of the .NET framework. 1.C# supports object-oriented programming (OOP), including encapsulation, inheritance and polymorphism. 2. Asynchronous programming in C# is implemented through async and await keywords to improve application responsiveness. 3. Use LINQ to process data collections concisely. 4. Common errors include null reference exceptions and index out-of-range exceptions. Debugging skills include using a debugger and exception handling. 5. Performance optimization includes using StringBuilder and avoiding unnecessary packing and unboxing.

From Web to Desktop: The Versatility of C# .NET From Web to Desktop: The Versatility of C# .NET Apr 15, 2025 am 12:07 AM

C#.NETisversatileforbothwebanddesktopdevelopment.1)Forweb,useASP.NETfordynamicapplications.2)Fordesktop,employWindowsFormsorWPFforrichinterfaces.3)UseXamarinforcross-platformdevelopment,enablingcodesharingacrossWindows,macOS,Linux,andmobiledevices.

The Continued Relevance of C# .NET: A Look at Current Usage The Continued Relevance of C# .NET: A Look at Current Usage Apr 16, 2025 am 12:07 AM

C#.NET is still important because it provides powerful tools and libraries that support multiple application development. 1) C# combines .NET framework to make development efficient and convenient. 2) C#'s type safety and garbage collection mechanism enhance its advantages. 3) .NET provides a cross-platform running environment and rich APIs, improving development flexibility.

See all articles