Building a Build Server – Building your first C# Project with Jenkins

In the previous article, titled Building a Build Server – Installing Jenkins, we installed Jenkins on the build server. In this article, we are going to configure our first C# project to be compiled by Jenkins. For now, we are going to directly execute MSBuild from the Jenkins configuration, but in the next article, we are going to install NAnt on the build server, so we can have better control over the build process.

Installing Cygwin Git

To be able to check out code from GitHub, we need a working installation of the git system on the build server. On way to add a git installation is to install the appropriate Cygwin packages. We are going to follow this path, because that will allow us later to use the rest of the Unix tools too.

Download the Cygwin installer from https://cygwin.com/install.html. Here, select the 32 or 64-bit version of the installer, depending on your build server. If it is a relatively new hardware and operating system, it is safe to assume that it is a 64-bit operating system, for which this is the Cygwin installer. Download and execute the installer.

After the installer starts, press next to start the installation process.

Select the option Install from Internet and click on Next.

Select C:\cygwin64 as your installation’s Root Directory. Install Cygwin for All Users.

Feel free to choose any directory for the local package directory. It is only used to cache the downloaded packages for further installation runs. You can also delete it after installation, if you want to free up the space.

In the “Select Your Internet Connection” configuration settings, we are going to select Direct Connection, but here, you can configure your connection settings in case you need to use proxy servers to access the internet from the server.

In the “Choose A Download Site” configuration settings, select any of the available download sites based on your preference. The only thing that they should be different in, is the connection speed because of where they are located.

In the “Select Package” window, search for git. In the Devel section click on the “Skip” text to set the binary package of git to install. Click Next to continue.

Accept the dependency resolution and click on Next to continue. Wait until the installation completes.

 

Feel free to add icons per your taste to the Cygwin shell. In future articles, we are going to use the shell to complete installation steps, because it is much easier and more accurate to provide shell commands for completing installation steps than textual descriptions on where to click.

 

On your Jenkins installation webpage, go to Manage Jenkins / Configure System and in the Global properties section, enable Environment variables, if it is not enabled and add the following:

Name

PATH

Value

%PATH%;C:\cygwin64\bin

Save changes.

Go to Manage Jenkins / Global Tool Configuration and in the Git section set the following:

Git

Name

Default

Path to Git executable

C:\cygwin64\bin\git.exe

Save changes.

Installing MSBuild

Install MSBuild from Visual Studio 2015, available from: https://www.microsoft.com/en-us/download/details.aspx?id=48159

On your Jenkins installation webpage, go to Manage Jenkins / Manage Plugins. Go to the Available Tab and in the filter type in MSBuild. Select the MSBuild plugin and click on Download now and install after restart button.

After Jenkins has been restarted, go to Manage Jenkins / Global Tool Configuration and in the MSBuild section add your MSBuild installation:

MSBuild

Name

MSBuild 14.0

Path to MSBuild

C:\Program Files (x86)\MSBuild\14.0\Bin

Save changes.

From the main Jenkins page, go to New Item and enter JenkinsHelloWorld, select Freestyle project then click Ok.

In the Source Code Management section of the configuration add the following, after selecting the Git option:

Repositories

Repository URL

https://github.com/atzimler/JenkinsHelloWorld.git

Branches to build

Branch Specifier (blank for ‘any’)

*/master

 

In the Build section of the configuration add the following:

Build a Visual Studio project or solution using MSBuild

MSBuild Version

MSBuild 14.0

MSBuild Build File

JenkinsHelloWorld.sln

Save changes.

On the JenkinsHelloWorld project page, press Build Now and you should see that the project is properly built. To test the application, go to C:\Jenkins\workspace\JenkinsHelloWorld\JenkinsHelloWorld\bin\Debug in a command line, and type JenkinsHelloWorld.exe. You should see the text “Hello World!”.

Subscribe to receive updates about my new articles by using the Follow me box below, as in the next article, we are going to install NAnt, to be able to build more sophisticated build instructions for our build system.

By subscribing to the email list, you will be notified about new posts.
Loading
No comments yet.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Powered by WordPress. Designed by WooThemes