There are different options available for implementing Build Automation on .Net Platform, however its very easy to implement Continuous Integration for DotNet using Jenkins, SVN and MSBuild.

First of all you will require to download and install latest build of Jenkins from their official website.

Here we assume that we are working with .Net Framework 3.5 (SP1), incase if you do not have DotNet Framework installed on your system get it from Microsoft’s Website or from FileHippo.

After your Jenkins is installed and running, access Jenkins Dashboard at – http://localhost:8080/

Here you need to follow these steps –

1) Download MSBuild Plugin for Jenkins – Click on Manage Jenkins > Manage Plugins. Here check the list of Available Plugins, choose MSBuild Plugin to install. This will allow us to use MSBuild.exe for compiling .proj or .sln of Visual Studio.

2) Configure Jenkins – Click on Manage Jenkins > Configure System. This will open ‘Configuration’ page. –

A) Below ‘Home Directory’ click on Advance button. Here you can select custom Folder for keeping ‘Workspace Root Directory’ (it will be used to check out the code files before making a build). Similarly you can select ‘Build Record Directory’ this will keep all the builds created.

B) MSBuild Segment – Give a name for the MSBuild installation which can be anything. Then provide ‘Path to MSBuild’, this has to be the folder where MSBuild.exe is installed (On my system its – C:\Windows\Microsoft.NET\Framework\v3.5\MSBuild.exe.

C) Email Notification – If you would like to receive email notifications on Unsuccessful Builds, provide credentials for SMTP mail server (by clicking on Advance button). In case if you don’t have any SMTP server available, you can also use your Gmail account for this purpose and use smtp details of Gmail. Don’t forget to check ‘Test configuration by sending test e-mail’ and send test email before saving settings.

D) Click Save button and Configuration is complete.
3) Create New Project- Now its time to add a Visual Studio Project/Solution and start a build job. –

A) Select ‘New Job’ option from Jenkins Dashboard. This will give you 4 different options to create a new Job (fifth job option – Copy Existing Job will also appear if you already have atleast one job created).

B) For building a .Net Solution we will choose first job option – Create a free-style software project.

C) Give name of the job and click OK button.

D) Now comes Configuration screen for the job.

E) For ‘Source Code Management’ choose ‘Subversion’. Here provide your SVN Repository URL (will be the same URL which is opened by your desktop SVN Client software. Such as at my system it’s the URL used by Repo Browser of TortoiseSVN). Specify Local Module Directory. This will be the folder where you want code of your project to be checked out.

F) Now you need to decide Build Triggers. This will decide when you want a new build to take place. If you want build should happen only if a new checkin has been made, select ‘Poll SCM’ option. Now provide the Schedule for polling  (such as- H/5 * * * *).

G) In ‘Build’ segment click on ‘Add Build Steps’ button and choose – ‘Build a Visual Studio project or solution using MSBuild’. After this select the ‘MSBuild Version’ which was added while configuring Jenkins. In ‘MSBuild Build File’ box give the name of Solution/Project file (such as – Company.MyGreatProj.sln) which needs to be built.

H) You can specify the ‘Post-build Actions’ such as Email Notifications in case of build failure.

I) Click Save button.

Once you are done with all these settings, its time to click on ‘Schedule A Build’ or open Job and click on Build Now. Once build starts, you can check the logs by opening ‘Console Output’. At first, you may get build errors because of any missing component. Such as for my one project, some third party controls were not installed and it failed at first. But in such cases Console Output logs are very helpful, go through it and check what exactly is going wrong (it may even be because of an unstable build).

The steps given here are for settings up a very basic Jenkins Build project. Jenkins is very flexible server with many Settings and can be tweaked a lot. Many Plugins are also available which allow you to go much beyond the basic build task.