Sponsored By Aspose - File Format APIs for .NET

Aspose are the market leader of .NET APIs for file business formats – natively work with DOCX, XLSX, PPT, PDF, MSG, MPP, images formats and many more!

CruiseControl, VS2008 and ASP.NET MVC

Everyone who e-mailed me asking about the realities of working down here, I will respond on this blog in the coming days. I need to take a break first and write on a technical topic since those seem to inspire far fewer e-mails for me to respond to.

Before I do, quick reminder that the South Florida Code Camp is this weekend in Miramar, which is somewhere ‘twixt Miami and Fort Lauderdale, I hope. Come check it out. There are twelve, count ’em, TWELVE tracks, including a Spanish one. I will be there in full hillbilly regalia chattin’ on MVC, TDD, and Brownfield development. Some awesome looking sessions too. I may duck out of my own MVC talk to see the one on For Love or More Money (which is co-presented by the uncannily-named David Silverlight). Anyway, back to our own little vaudeville here…

I’m setting up a brand new ASP.NET MVC project and I’ve created for it a shiny new NAnt build file that performs the following steps, in order:

  • Compiles the application

I want to do this in baby steps, you see. My goal is to get everything into CruiseControl as quickly as possible and for the time being, all I need is to compile the app. After that’s done, I’ll start adding test projects, test targets, deployment packages, real code, and so on and so forth. But first, CI.

Harder than one might think, don’t you know, and the rest of this post will consist of various error messages and the minor tweaks involved in getting around them.

Getting the build file to compile the app on my local machine was relatively straightforward thanks, once again, to Jeff Palermo’s CodeCampServer sample project. There was one minor hiccup in that the version of NAnt I had didn’t like the 3.5 framework but Jeff already had that covered.

So I copy and paste my way through setting up the project on my build server and lo!

BUILD FAILED

Failed to initialize the 'Microsoft .NET Framework 2.0' (net-2.0) target framework.

Property evaluation failed.
Expression: ${path::combine(sdkInstallRoot, 'bin')}

Google helps me determine that this has been fixed in the latest nightly build for NAnt. So bada-build-bing, I switch to the uber-latest version of NAnt, check it works locally, check in to Subversion and wait for the build to complete:

./Trilogy.Gunton.sln(2): Solution file error MSB5014: File format version 
is not recognized. MSBuild can only read solution files between versions 7.0
and 9.0, inclusive.

External Program Failed:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\msbuild.exe (return code was 1)

Fix for this was to read Jeff Palermo’s previous post *all* the way through and set the nant.settings.currentframework property to net-3.5 in my build file. Which leads to the next error:

C:\data\ccnet\Trilogy.Gunton\src\app\Trilogy.Gunton.Web\Trilogy.Gunton.Web.csproj(89,11):
error MSB4019: The imported project
"C:\Program Files\MSBuild\Microsoft\VisualStudio\v9.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.
External Program Failed: C:\WINDOWS\Microsoft.NET\Framework\v3.5\msbuild.exe
(return code was 1)

This was an interesting one in that I found a solution right away but didn’t much like it. It says to copy the Microsoft.WebApplications.targets file to your solution directory, then modify your .csproj file directly so that it uses the copied file rather than the one it’s expecting in Program Files.

What I don’t like about the solution is that it involves copying a file that might change. Plus, it’s seems more than a little subversive. Having said that, the only other solution I found was to install a version of Visual Studio on the build server and blimey, I’m surprised how many people think that’s okay. I’ll have to pick someone’s brain on that because it feels really, really wrong. But I’ve gotten used to worse.

Anyway, in the end, I went with copying the targets file to my solution directory. Note: in order to pass the SolutionDir variable to MSBuild from NAnt, as the link suggests, you pass it in through the /p switch. Example:

<exec program="${framework::get-framework-directory(framework::get-target-framework())}\msbuild.exe" 
    commandline="${solution.file} /t:Rebuild /p:Configuration=Debug;SolutionDir=${current.dir} /v:q" workingdir="." />

After that, it worked!

OK, that’s a lie. The next error was thus:

Controllers\HomeController.cs(3,18): error CS0234: The type or 
namespace name 'Mvc' does not exist in the namespace 'System.Web'
(are you missing an assembly reference?)

This was a fairly easy one. I could either install the ASP.NET Web Extensions CTP on the build server or reference all the relevant assemblies locally. I chose the former because the eventual production server will need to have it installed anyway.

So here’s hoping this string of errors helps a soul as lost as mine.

Kyle the Cruised

This entry was posted in ASP.NET MVC, Continuous Integration. Bookmark the permalink. Follow any comments here with the RSS feed for this post.
  • http://twitter.com/sjkilleen Sean Killeen

    Just wanted to say thank you so much! Even 3 years later, this post is in the process of helping me solve my beginning foray into CruiseControl .NET. Using VS 2010, MVC3, and CCNet, the same problem still exists. This has been the single best point of insight I could come across on the topic. Much appreciated!

  • http://codebetter.com/blogs/kyle.baley Kyle Baley

    The event was on the 2nd. You’ll have to wait until next year. Or make the trip up to Orlando for their code camp on March 22.

  • http://ifwdev.wordpress.com Will Sahatdjian

    I live a few miles away from this event but it appears registration is closed? You think they will turn me away if I show up?

  • http://www.jeffreypalermo.com Jeffrey Palermo

    @Kyle,
    Glad to help!

  • http://www.opgenorth.net Tom Opgenorth

    You kids and your fancy MSBUILD.EXE. Why, back in my day, we compiled using the csc task from Nant, and we liked it. Serves you right for trying out these new fangled fancy things.

    :)