Last Updated: February 25, 2016
·
7.92K
· kjellski

Getting TeamCity to build ASP.net MVC 3+ Web Solutions

I'm currently integrating CI into our development and deployment process. Here is one Problem I ran into:

I was following along the beatufully collected informations on Troy Hunts Blog when suddenly an error occured:

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.

TeamCity is trying to tell me that I don't have the Visual Studio 2012 Web Application Support installed. Unfortunately, I won't do that, mainly because of licensing issues.

But there is an easy solution to this. Install the MSBuild.Microsoft.VisualStudio.Web.targets Package into your Solution and replace the old reference:

<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />

With this new one, which would use the NuGet installed package:

<Import Project="..\packages\MSBuild.Microsoft.VisualStudio.Web.targets.11.0.2.1\tools\VSToolsPath\WebApplications\Microsoft.WebApplication.targets" Condition="true" />

Hope this helps.

EDIT: I've just had the same thing again today, and I noticed that I forgot to mention, that this all is nice and fine, but you need to provide an ApplicationPool and SiteName as a 'DeployIisAppPath' too, like this:

<DeployIisAppPath>AppPool/SiteName</DeployIisAppPath>

You have to put it under your configurations property group for the project. For me it's always the second or third(Debug/Release) property group xml tag, it looks similar to this:

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">

Greetings,
Kjellski

5 Responses
Add your response

It helped a lot. Thanks!

over 1 year ago ·

Yes! :-D

over 1 year ago ·

Thanks - i had found the targets install for Nuget but there were no instructions

over 1 year ago ·

I've made an edit to save you the next tripwire, right arround the corner ;)

over 1 year ago ·

Yeah, I was really wondering how to deal with this myself, glad it helped! :)

over 1 year ago ·