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
  • 12,269
  • 16
  • 84
  • 118

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,178
  • 3
  • 43
  • 57
0

You pass another property to msbuild:

<Target Name="Deploy" DependsOnTargets="Build">
        <MSBuild Projects="MyProject.sln" Properties="...SkipExtraFilesOnServer=False..."/>
</Target>
Jim Aho
  • 7,796
  • 11
  • 49
  • 80