74

I want to package my VS2010 web application project ready for deployment with msdeploy. On development machine I can do this using:

MSBuild.exe "C:\path\to\WebApp.csproj" /target:package

But on my build server I get this error:

error MSB4057: The target "package" does not exist in the project.

What am I missing on the build server?

Jeroen
  • 53,290
  • 30
  • 172
  • 279
Andrew Davey
  • 5,305
  • 3
  • 40
  • 57

7 Answers7

112

I just got this working without installing VS2010 by following these steps on the build server:

  1. If .NET Framework 4 isn't installed, install it
  2. Install the Web Deployment tool from http://www.iis.net/download/webdeploy
  3. From the C:\Program Files\MSBuild\Microsoft\VisualStudio\v10.0 folder on your dev machine copy the "Web" and "Web Applications" folders to the equivalent directory on your build server.

This seems to work for me

spmason
  • 3,933
  • 2
  • 21
  • 19
  • 3
    Also make sure that you use the .net 4 version of MSBuild.exe! (in %windows%\Microsoft.net\Framework\v4.0.30319) – AndyM Oct 07 '10 at 09:12
  • 8
    In my case the problem was that I had copied accross the "Web Applications" folder, but not the "Web" folder. – willem Jun 09 '11 at 11:46
  • 3
    +1 Note the `C:\Program Files` bit will be `c:\Program Files (x86)` if you're running 32 bit MSBuild on a 64 bit machine [like in my case] (In my case the `Web` portion was the missing ingredient - I assume `Microsoft.WebApplications.targets` and/or are silently ignoring the absence of the `Microsoft.Web.Publishing`.*`.targets`) – Ruben Bartelink Jun 28 '12 at 10:03
  • 5
    Thanks! for me the critical missing folder was C:\Program Files\MSBuild\Microsoft\VisualStudio\v10.0\Web I had "WebApplications" already, but not the "Web" folder – brodie Jul 25 '12 at 01:26
  • I was having the same issue, I copied the files over from my dev to the Sevrer and it finally worked!!! fantastic!! – Andy Clark Sep 19 '12 at 16:01
  • Also had the same horrible issue with no sensible error message. I had original built the proj in vs2012 and had copied the webapplication msbuild folder over but not the web. So happy. Thanks! – Sam Oct 31 '12 at 06:56
  • On TFS 2012, I had to install Visual Studio 2012 with "Web Developer Tools". – Scott Stafford Nov 07 '12 at 16:51
  • I had the same issue and the copying the Web folder onto my build server fixed the problem. Thanks – Ryan Spears Dec 21 '12 at 01:37
  • @spmason thanks - this has made my day. was crying previously trying to get msbuild working on staging server. – Tom Miller Feb 22 '13 at 11:35
  • 2
    It fixed my problem with 2 corrections: 1. Program Files (x86) 2. "MSBuild\Microsoft\VisualStudio" has 3 subdirectories: v10.0, v11.0, v12.0. I am using VS 2013 (v12.0). However the problem only cleared after I copied Web folder from V10.0 to v11.0. It may be worth mentioning that the problem started after I uninstaller VS 2012. – Gregory Khrapunovich Jan 07 '15 at 22:23
10

I know it's an old question, but I recently ran into the same issue and none of the answers helped. I was missing following file on my build server:

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio
    \v11.0\Web\Microsoft.Web.Publishing.targets

It is imported by:

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio
    \v11.0\WebApplications\Microsoft.WebApplication.targets

Hope this helps someone like me :)

Ruben Bartelink
  • 55,135
  • 22
  • 172
  • 222
joozek
  • 2,007
  • 2
  • 21
  • 30
  • 2
    worked for me... I had copied the webapplications target folder but not the web folder... the build would succeed but would just not deploy – jdmonty Jan 30 '14 at 02:03
  • This was the issue for me with Visual Studio Build Tools 2017. I had not selected the "Web development build tools" workload, so the web publishing target was not installed. Modifying the installation to include that fixed it. – Jeffrey Harmon Mar 10 '17 at 01:07
5

You may install MSBuild.Microsoft.VisualStudio.Web.targets package. No need to manually copy targets to build server.

Der_Meister
  • 4,413
  • 2
  • 38
  • 47
4

I experienced the same issue. Ended up resolving by adding this:

<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>

<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

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

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

to my .csproj fiie.

contrashadow
  • 151
  • 1
  • 5
1

You need to have .Net 4.0 installed on the build server. The .Net 4.0 install will put the new MSBuild 4.0 which supports packaging web application projects.

Also, when you are running msbuild.exe make sure you are running the one that sits in the .Net 4.0 framework folder.

Paul Lemke
  • 5,255
  • 3
  • 45
  • 66
-1

Also consider using msbuild with version, corresponding to Web Deployment tool version. I have faced same problem as the OP. The solution was to change msbuild from 4.5 to 4.0 on buildServer.

elixenide
  • 42,388
  • 14
  • 70
  • 93
-3

To solve this problem install Visual Studio 2010 on the build server and make sure you installed Visual Web Developer feature.

Fitzchak Yitzchaki
  • 8,867
  • 7
  • 51
  • 94
  • 5
    It is not necessary to install Visual Studio on the build server. The build/deploy process only depends on a handful of files (see spmason's post) – Noah Heldman Mar 15 '11 at 04:47