MSBuild target package not found

2020-01-24 21:00发布

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?

7条回答
等我变得足够好
2楼-- · 2020-01-24 21:04

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

查看更多
在下西门庆
3楼-- · 2020-01-24 21:10

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.

查看更多
不美不萌又怎样
4楼-- · 2020-01-24 21:11

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.

查看更多
霸刀☆藐视天下
5楼-- · 2020-01-24 21:15

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

查看更多
成全新的幸福
6楼-- · 2020-01-24 21:19

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.

查看更多
相关推荐>>
7楼-- · 2020-01-24 21:21

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 :)

查看更多
登录 后发表回答