5
votes

I am creating a build script to automate the publishing of our web projects to a testing machine.

I have a msbuild script which successfully does this, however when it is running it generates an error for each project in the solution stating that "The target "_WPPCopyWebApplication" does not exist in the project".

It is correct because in each of my project files I do not import the relevant .targets file that contains this function.

If I do change each of the project files to import the .targets file then instead of the errors I get a warning for each project stating that

MSBuild\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.targets" cannot be imported again.

It was already imported at "MSBuild\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets (354,3)". This is most likely a build authoring error. This subsequent import will be ignored.

At the moment I import the relevant .targets files at the top of my build script:

<Project ToolsVersion="4.0"
     xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

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

Is there a way to prevent the error stating that the "_WPPCopyWebApplication" is not present in the project file without generating the warning stating that there are duplicate imports after I add it to each project file?

Why do the projects need to import the targets file if it is imported at the top of my build script?

Edit:

I am currently using _WPPCopyWebApplication like this:

<Target Name="Publish" >
<RemoveDir Directories="$(OutputFolder)" ContinueOnError="true" />
<MSBuild Projects="myproject.csproj;anotherproject.csproj" Targets="ResolveReferences;_WPPCopyWebApplication" Properties="WebProjectOutputDir=$(OutputFolder);OutDir=$(WebProjectOutputDir)\" />
</Target>

Which I got from here and here:

1
Have you tried to add to the MSBUIld task properties CleanWebProjectOutputDir=False ?sll

1 Answers

4
votes

You are getting that error because Microsoft.WebApplication.targets already imports Microsoft.Web.Publishing.targets.

http://www.asp.net/web-forms/tutorials/deployment/web-deployment-in-the-enterprise/building-and-packaging-web-application-projects

How Does the WPP Work?

The Microsoft.WebApplication.targets file in turn imports the Microsoft.Web.Publishing.targets file. The Microsoft.Web.Publishing.targets file essentially is the WPP. It defines targets, like Package and MSDeployPublish, that invoke Web Deploy to complete various deployment tasks.