Showing posts with label TeamCity. Show all posts
Showing posts with label TeamCity. Show all posts

Wednesday, 13 November 2013

Running MS Test on Team City without installing Visual Studio

One of the challenges if you are using MS Test has always been being able to run the tests on your Team City server without installing Visual Studio.

The reason for this is that MS Test expects assemblies in the GAC, registry entries, as well as other assemblies outside the GAC.

Now it is possible to pick apart what’s needed and install it all manually (as this post details) but that’s a lot of effort and it only takes one thing to be wrong and nothing’s going to work.

In the past I was faced with this challenge and started down the route of doing the manual install (which went wrong) and then I discovered Visual Studio Agents.

Visual studio agents are what you would use if you had on premise TFS Build server and wanted to add additional servers to support the build, the agent doesn’t contain the entire Visual Studio but does have just the bits you need to run things such as MS Test.

There are versions of the agents from VS2008 through to VS2013 so you should be covered whatever version of VS you are using.

Yes for the purists out there this does mean there is more on your CI server than just what’s needed to run your code, but we are talking about MS Test here Winking smile

Tuesday, 23 October 2012

Build errors with TeamCity, MSBuild, MVC Build Views and .Net 4.5

Recently I moved an application from .Net 4.0 & MVC3 to .Net 4.5 & MVC4 which for the most part went fairly painlessly.

Previous to the .Net 4.5 upgrade the code was already being built and tested on TeamCity, but as part of the upgrade exercise it was decided to implement deployment from TeamCity using web deploy to a test server.

Getting web deploy set up on TeamCity is fairly painless and Troy Hunt has a nice set of posts about this, what it generally boils down to is using MSBuild to package the code and then calling web deploy to use the newly created package.

I set up the necessary build steps only to find that I was getting build failures on TeamCity when using the MSBuild runner (previously had used VS Solution runner) with the following error:

ASPNETCOMPILER error ASPRUNTIME: Could not load file or assembly 'System.Web.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
Project XYZ\XYZ.csproj failed.
Project XYZ.Tests\XYZ.Tests.csproj failed. Project ABC.sln failed.

I appeared to be able to solve this by adding an additional MSBuild property /p:VisualStudioVersion=11.0 which I found from this stack overflow answer.

Once done the code then built successfully but when it then attempted to package and deploy the web site it was failing with the error:

MvcBuildViews AspNetCompiler
AspNetCompiler C:\TeamCity\buildAgent\work\f2cfe4b9b1db787a\XYZ\obj\uat\csautoparameterize\original\web.config(27, 0): error ASPCONFIG: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.

I quickly discovered that this was an issue with the package command and happened because the obj folder wasn’t deleted, normally you get around this by altering the project file and telling it to use a different folder to output files to but this didn’t work for me. 

After much searching I finally found the answer with this comment on a Phil Haack's blog post where I needed to add another MSBuild parameter /p:BaseIntermediateOutputPath=<your path here> which then allowed the TeamCity agent to create the package and successfully execute web deploy.

This took me a couple of days to resolve and the initial problem was that I had just upgraded to TeamCity 7.1 and incorrectly suspected it of causing me the problem, I was wrong.

Hopefully this post will help you if you too run into the problem.