At work, we use TeamCity as our continuous integration build server. Since upgrading to Visual Studio 2015, one of the things we needed to do was upgrade TeamCity to support building the new Visual Studio 2015 solutions and projects.

I initially thought this would be a nightmare as we were running an older version (8.0.5) released in November 2013! To my surprise upgrading to the latest version (9.1) was relatively straightforward, however, we did come across a few issues getting the solutions to build, so I thought I’d share how we solved them.

Note: Before you start your TeamCity upgrade, make sure you backup you current configuration. You can do this by going into the TeamCity administration area and selecting ‘Backup’. Official upgrade documentation here.

Once TeamCity 9.1 has been installed, you’ll need to upgrade your current build configurations to use the new MSBuild version, meaning it will compile new C# 6.0 language syntax/features such as string interpolation, null condition operators and expression-bodied function members. Set the MSBuild version property to “Microsoft Build Tools 2015” and MSBuild ToolsVersion to “14.0”.

TeamCityBuildConfig

Once you’ve done that, run a test build. If your build outputs the error message “Unmet requirements: MSBuildTools14.0_x86_Path exists“, install the Microsoft Build Tools 2015. For some reason it took me a while to find this package as the first search result that came up in Google was for the release candidate (RC) version. I eventually found it on the Visual Studio downloads page under the heading “Tools for Visual Studio 2015”. Once this has been installed, remember to restart the TeamCity services. You’ll also need to install the .NET 4.6 framework if your projects are targeting it.

The final build error we faced concerned build targets. You might see something like this:

error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.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, copy across the “WebApplications” targets folder from your local development machine (I’m not sure of a better way to do this yet), which is on the same path. Our solutions have DeployOnBuild set to true, so we also had to copy the “Web” targets folder.

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\WebApplications

Once these were issues were sorted, our build server was finally happy again.