qvrchq
Last Updated: February 25, 2016
·
6.426K
· kjellski
Gavatar big

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

Say Thanks
Respond

5 Responses
Add your response

12142
0aea3102801a8a29d058b1db79d4dca3

It helped a lot. Thanks!

over 1 year ago ·
13720
Eacb9048920f2d316d7f45b0f40688e6

Yes! :-D

over 1 year ago ·
14875
602987bdd5f801f674b33193b26dcaf9

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

over 1 year ago ·
14879
Gavatar big

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

over 1 year ago ·
14880
Gavatar big

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

over 1 year ago ·
Awesome Job

20838750 ca12 11e7 8395 3d07316c018d
Overijssel,Amsterdam, Arnhem
·
Overijssel, Amsterdam, Arnhem
·
Full Time