19

Visual Studio 2010 seems to insist on having this import in web application projects

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

What does this import give us and is it really required?

On a side note if you remove this import with a text editor Visual studio will re-add it.

The reason i am asking is when the project is compiled on a build server that target does nor exists because visual studio is not installed.

Simon
  • 33,714
  • 21
  • 133
  • 202

4 Answers4

12

As suggested in the comments to Raj Kaimal's answer, to get this working you can copy over the folder to the same location on the build machine.

If you want, you can also put that folder somewhere else in your machine, even relative to your project. You just need to add something to the csproj to redirect MSBuildExtensionsPath..

For example, I have the following in my csproj (works for VS2010 and VS2012):

<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
<PropertyGroup>
    <MSBuildExtensionsPath32>..\lib\MSBuild.MSVS\</MSBuildExtensionsPath32>
</PropertyGroup>  
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets"/>

Then, within my lib folder (which is a sibling of the folder containing the csproj), I have copied the following directories:

  1. %ProgramFiles%\MSBuild\Microsoft\VisualStudio\v10.0\WebApplications → MSBuild.MSVS\Microsoft\VisualStudio\v10.0\WebApplications
  2. %ProgramFiles%\MSBuild\Microsoft\VisualStudio\v10.0\Web → MSBuild.MSVS\Microsoft\VisualStudio\v10.0\Web
Frank Schwieterman
  • 24,142
  • 15
  • 92
  • 130
4

Contains entries for MSBuild C:\Program Files\MSBuild\Microsoft\VisualStudio\v10.0\WebApplications

Use the publish option in VS 2010 to create a zip package that you can deploy on your server (MS Deploy)

read this: http://vishaljoshi.blogspot.com/2009/03/how-does-web-deployment-with-vs-10.html

What build server are you using?

Raj Kaimal
  • 8,304
  • 27
  • 18
  • 1
    Copy the contents of the path above and put it in the same path on your bulid server. Ensure .NET 4 is installed on the build server. Try building. – Raj Kaimal Apr 28 '10 at 03:44
  • 1
    not so easy when a 3rd party owns the build server http://teamcity.codebetter.com/overview.html . But i will ask them – Simon Apr 28 '10 at 05:29
  • turns out it is a little more complicated than that http://richardsbraindump.blogspot.com/2009/11/how-to-build-vs2010-solutions-using.html – Simon Apr 28 '10 at 06:14
3

We have a situation where our CI build server also hosts some web sites. It doesn't have a version of Visual Studio installed, so the link to the MSBuildExtensions broke our build on the upgrade to vs2010/.net4.0.

It seems like overkill to have to install VS2010 on the build machine if it's not a dev machine as well... could I just install the MSBuild Extension Pack (http://msbuildextensionpack.codeplex.com/) on the build server and have it work out alright? I currently can't verify that this works, but from what I was able to accomplish prior to this post, it seems like a better option than installing VS2010.

-Daniel

DMac the Destroyer
  • 5,240
  • 6
  • 36
  • 56
  • 3
    good point daniel. although your post should be a comment not an answer – Simon Sep 02 '10 at 04:35
  • I tried this and unfortunately I don't think the MSBuild Extension Pack includes the WebApplications target, the one mentioned in this question. – Sean May 10 '13 at 02:03
0

If you don't deploy from the build server, then you can turn off the Microsoft.WebApplication.targets on the build server. See my answer here: https://stackoverflow.com/a/35781566/4955344

Community
  • 1
  • 1
Alex R.
  • 644
  • 6
  • 9