8
votes

I'm using the _WPPCopyWebApplication MSBuild target in a CruiseControl.net build-and-deploy script, but it appears that this target cleans files not part of the project before the deployment - specifically, App_Data files (which for this app, include uploaded images, etc).

From Microsoft.Web.Publishing.targets;

<OnBefore_WPPCopyWebApplication>
    $(OnBefore_WPPCopyWebApplication);
    CleanWebProjectOutputDir;
    PipelineTransformPhase;
</OnBefore_WPPCopyWebApplication>

How can I stop it doing the CleanWebProjectOutputDir, given this target;

<Target Name="Deploy" DependsOnTargets="Tests">
    <MSBuild Projects="$(TargetPath)Website.csproj" Properties="Configuration=Debug;WebProjectOutputDir=\\servername\share;Outdir=$(ProjectDir)bin\;" Targets="ResolveReferences;_WPPCopyWebApplication" />
</Target>

This is from a VS2010 solution, albeit built under CC.Net; I'm aware of MSDeploy, but haven't got my head around that fully yet, so would prefer to stick with MSBuild/_WPPCopyWebApplication for now.

EDIT:

I've further narrowed this to this part of the target;

<!-- In the case of the incremental Packaging/Publish, we need to find out the extra file and delee them-->
<ItemGroup>
    <_AllExtraFilesUnderProjectOuputFolder Include="$(WebProjectOutputDir)\**" />
    <_AllExtraFilesUnderProjectOuputFolder Remove="@(FilesForPackagingFromProject->'$(WebProjectOutputDir)\%(DestinationRelativePath)')" />
</ItemGroup>
<!--Remove all extra files in the temp folder that's not in the @(FilesForPackagingFromProject-->
<Delete Files="@(_AllExtraFilesUnderProjectOuputFolder)" />

So I guess the question becomes, how can I supress this specific Delete task, or at least add App_Data** to the _AllExtraFilesUnderProjectOuputFolder exclusions?

1

1 Answers

9
votes

Add CleanWebProjectOutputDir=False to your properties:

<Target Name="Deploy" DependsOnTargets="Tests">
    <MSBuild Projects="$(TargetPath)Website.csproj" Properties="Configuration=Debug;CleanWebProjectOutputDir=False;WebProjectOutputDir=\\servername\share;Outdir=$(ProjectDir)bin\;" Targets="ResolveReferences;_WPPCopyWebApplication" />
</Target>