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
Written by @kjellski
Related protips
5 Responses

It helped a lot. Thanks!

Yes! :-D

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

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

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