Friday, 24 August 2012

Building .Net 4.5 Projects with Jenkins

In my day job for Specialmoves we use Jenkins as our continuous integration server.

Today, after upgrading one of our projects to target .Net 4.5, a colleague of mine was complaining  that the Jenkins build for the project was failing with the following error.

warning MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.5" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed.

He had already tried installing .Net 4.5 on the Jenkins server, which hadn't fixed the problem.

Chuck Norris was not amused....... 

(if you haven't installed the Chuck Norris plugin for Jenkins, i suggest you do so immediately. It wont fix your problem, but it will make you laugh)

The first thing we had to do was to install the Windows SDK for Windows 8 on the Jenkins server. This 
includes the .NET Framework 4.5 SDK

After installing the SDK, we kicked off the build again, only to be greeted with a different error.

error MSB4019:  The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk

To fix this error we copied the missing Visual Studio 2012 msbuild folder from a machine that actually had Visual Studio 2012 installed.

So copy C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\ from a machine that has Visual Studio 2012 installed, to the same location on the Jenkins server.

Once you've done this, Jenkins should be able to build the project.

Chuck Norris is happy again.