3

When I build and deploy using Visual Studio, I can choose to 'remove additional files at destination'.

How can I do this with MSBuild? As the additional files will vary, I can't just use the Remove and RemoveDir tasks.

Jonathan
  • 13,947
  • 17
  • 94
  • 123

2 Answers2

6

If you have a publish profile (.pubxml), I believe using this is analagous to checking the 'remove additional files at destination'

<SkipExtraFilesOnServer>False</SkipExtraFilesOnServer>

Then referencing the Publish Profile in msbuild:

<MSBuild Projects="proj.csproj"
         Targets="WebPublish"
         Properties="VisualStudioVersion=11.0;
          Configuration=$(Configuration);
          PublishProfile=$(Configuration).pubxml;
          MSDeployServiceUrl=$(ServiceUrl);
          UserName=$(MSDeployUsername);
          Password=$(MSDeployPassword)"  />

If not using publish profile, I'd think just adding the SkipExtraFilesOnServer=False in the build task properties would do the trick.

RyanW
  • 5,338
  • 4
  • 46
  • 58
0

You pass another property to msbuild:

<Target Name="Deploy" DependsOnTargets="Build">
        <MSBuild Projects="MyProject.sln" Properties="...SkipExtraFilesOnServer=False..."/>
</Target>
Jim Aho
  • 9,932
  • 15
  • 56
  • 87