English 中文(简体)
MSBuild target package not found
原标题:

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	oWebApp.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?

最佳回答

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 FilesMSBuildMicrosoftVisualStudiov10.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

问题回答

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)MSBuildMicrosoftVisualStudio
    v11.0WebMicrosoft.Web.Publishing.targets

It is imported by:

C:Program Files (x86)MSBuildMicrosoftVisualStudio
    v11.0WebApplicationsMicrosoft.WebApplication.targets

Hope this helps someone like me :)

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

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

<PropertyGroup>
<VisualStudioVersion Condition=" $(VisualStudioVersion)  ==   ">10.0</VisualStudioVersion>
<VSToolsPath Condition=" $(VSToolsPath)  ==   ">$(MSBuildExtensionsPath32)MicrosoftVisualStudiov$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>

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

<Import Project="$(VSToolsPath)WebApplicationsMicrosoft.WebApplication.targets" Condition=" $(VSToolsPath)  !=   " />

<Import Project="$(MSBuildExtensionsPath32)MicrosoftVisualStudiov10.0WebApplicationsMicrosoft.WebApplication.targets" Condition="false" />

to my .csproj fiie.

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.

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.





相关问题
How can I overwrite file web.config with web.other.config?

I have a msbuild script with custom logic to deploy my service to the qa server automatically. I have to overwrite the default config with a dedicated one, but when I use <Copy SourceFiles="web....

How do I use MSBuild on a C# project with no compilable code

I have a C# web app project which actually has no ASP.Net or C# in it. It s just a single html page with some Javascript, CSS, and a couple of images. I want to use MSBuild to deploy a version of ...

您能否防止MSBuild.exe经营活动?

我用文字建造一些项目,偶尔利用习俗制造事件,给建筑系统造成了很大困难。 如果有可能,我想援引MSBuild.exe。

building .net applications without Visual Studio

I m interested to hear about people working with building .net applications using MSBuild, NAnt or similar tools. What are you using, why are you using it instead of the VS IDE? I like to use ...

How long does my Visual Studio C# compile take?

It seems like it should be possible to configure Visual Studio to print out how long the compile takes. Perhaps somewhere in the .sln file. If the sln is compiled from the command line using ...

热门标签