At the end of last year, thanks to the company's introduction to Jenkins, we took the first step in continuous integration, and this article does not dwell on how to install Jenkins, and the main focus is on configuring the. Net environment. In addition, this article is installed in the Windows environment of Jenkins to operate.
First, installation environment
First we need to prepare several installation packages to 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 is of course the familiar. NET Framework operating environment;
The second is MSBuild, although we use Visual Studio to compile and publish programs in a graphical interface, but actually Visual Studio is going to invoke MSBuild to do all sorts of things, so we want Jenkins to be able to compile the code automatically, as well as prepare it A set of MSBuild.
The third package, the. NET Framework 4.6.1 Developer Pack (Developer Pack), was formerly known as the Targeting pack, which contained a bunch of assemblies. Like earlier versions of Visual Studio 2013, when it was released, there was No. NET Framework 4.6.1, and it was necessary to install the developer package if it was to be supported. If you do not install it, you will be prompted for the System.Object, System.Attribute assembly error when you post-compile the 4.6.1 program. 4.6.1 's developer Pack contains 4.0, 4.5, 4.6 targeting pack content, and installing 4.6.1 packages does not require the installation of 4.0 other versions of the package. In addition, if you need Chinese support, you need to install the English version, and then install the Chinese language pack.
The last NuGet console program requires NuGet for package restore before compiling the program. This software does not need to install, put in a fixed position on the line, for example, placed under the D:\Tools\CI.
Second, install Jenkins plug-in
Go to the Plugin Administration page of Jenkins and install the MSBuild plugin at the address: https://wiki.jenkins-ci.org/display/JENKINS/MSBuild+Plugin
After installation, enter the "Global Tool Configuration" interface:
In the open page, find the "MSBuild" column, click "MSBuild Install", and then click the "New MSBuild" button, you can configure the path of the MSBuild.exe. Since I use 32-bit MSBuild, I can configure this:
Default installation path for MSBuild
32 Guests |
C:\Program Files (x86) \msbuild\14.0\bin\msbuild.exe |
64 guests |
C:\Program Files (x86) \msbuild\14.0\bin\amd64\msbuild.exe |
Don't forget to save after you've configured it.
Third, Jenkins Job configuration
Ready to run the environment and Jenkins plugin, we create a new Job to try. Our company is using Subversion, so I will download the code from SVN, using Git and other warehouses are similar, this is skipped.
1. Restore NuGet Packages
We need to add a "Execute Windows Batch command" step in the "Build" column for the NuGet package restore
1 D:\tools\CI\nuget.exe Restore \yoursolutionname.sln
The first is to specify the path to the Nuget.exe, and then use the RESTORE command to package restore the YourSolutionName.sln solution file under the current directory. Everyone according to their actual situation to modify can.
2. Configuring MSBuild Compilation Parameters
Still in the "Build" column, create a new "build a Visual Studio project or solution using MSBuild" (Build VS project or solution using MSBuild) step
From the top down, in turn,
The main point here is "Command line Arguments" configuration, a more comprehensive MSBuild documentation can be found in msdn:https://msdn.microsoft.com/zh-cn/library/dd393574.aspx
I want to generate an 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 Specifies the sub-toolset (https://msdn.microsoft.com/zh-cn/library/bb383796.aspx) version, does not set the error
/p:deployonbuild=true; Publishprofile=testing-environment-ci-publish Publishing a project by using Testing-environment-ci-publish.pubxml Publish file
Iv. Supplementary
[January 24, 2017 09:30 UPDATE]
Sorry, I missed this when I published the article last night. If you compile the project by using MSBuild as configured above, you may encounter errors such as:
Imported items not found "C:\Program Files (x86) \msbuild\microsoft\visualstudio\v14.0\webapplications\ Microsoft.WebApplication.targets "
Just find a computer with Visual Studio 2015 installed and copy all of the contents of the C:\Program Files (x86) \msbuild\microsoft\visualstudio\v14.0 directory to Jenkins This directory where the Windows system is located, and then rebuild it.
There may also be some content on the Jenkins integrated xunit.net unit Test and auto-release, but I don't know if I can send it out years ago. XD
Hope the article can have a role for everyone.