Setting up MsBuild on Windows Server Without Visual Studio

Tuesday, April 17, 2012

Okay, so I have server that has a newly installed Windows Server on it. I want to set up a server that reads a SVN code repository and does automated builds on a periodic basis. We are not using TFS nor Visual Studio on the server, so the tool of choice I am going to go with is TeamCity with MsBuild. Seems pretty straight forward, right?

Not so fast grasshopper! There’s a few things MsBuild needs to successfully complete a build, and it’s not so obvious right off the bat that you need them.

So, in this post, I am going to discuss what it took for me to get a solution to build on a server that does not have Visual Studio installed on it.

First The Obvious

The solution contains several MVC 3 projects, a class library, and a test project that right now is using Microsoft Test. So with that in mind, the first thing I need to do is get the 4.0 .Net Framework and install it on the server.

Running MsBuild

Okay, the framework is installed, I downloaded the latest code from the source control repository; let’s run MsBuild and watch our project build. After all; It runs on my development machine, and all the files and dll’s are checked in so my project should build correct?


error MSB4019: The imported project "C:\Program Files\MSBuild\Microsoft\VisualStudio\v10.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.

Hmm, okay off to StackOverflow!

Okay, I have two options for this one. Install Visual Studio on the build machine or copy the WebApplication folder that is on my development machine, to the exact same folder structure that the MsBuild script is saying where the folder is missing.

So now the server has that folder in location it is looking for so all should be good. Now let me run the build script again.


Oh! it's saying it can’t find the assembly System.Web.Mvc. Woops, I recall that MVC 3 was released after the .Net Framework was release, so that makes sense. Okay let me go to the ASP.NET MVC 3 website and install the MVC 3 framework.

So now the server has MVC 3 install so I should definitely be good now! Let’s run the script again.


Now MsBuild is saying it can’t find the assembly System.Web.Helpers. That wasn’t loaded with the MVC 3 download? I guess not. Okay, off to StackOverflow again!

Okay, so now apparently I need to install the Microsoft Windows SDK for Windows 7 and .NET Framework 4. Whaaa? I just installed the Framework, and MVC 3 and that wasn’t enough? Well, if you say so.

So now item number 4 is fixed, everything should be good, correct?


MsBuild is now saying it is missing assembly microsoft.visualstudio.qualitytools.unittestframework!

Off to StackOverflow AGAIN!!!

So apparently there is no getting around this one. Either I install Visual Studio on the build server, or I remove the MsTest project from my solution.

It’s a build server! I don’t want to install Visual Studio. Let me remove that project and see what happens.


Okay, nUnit it is! Just need the assembly in bin directory, and most CI tools like TeamCity will run nUnit tests, and to me more importantly is that Resharper's testing integration will respect nUnit test too so I'm good.


So if you are going to create a build server and not install Visual Studio on the box, here what you need to install and configure for a .Net solution that has some MVC projects and nUnit:


Hope this helps.


comments powered by Disqus