MSDeploy skip rules when using MSBuild PublishProfile with Visual Studio 2012

Edit: It turns out you are right: the skip directive is ignored when executed from Visual Studio.

Fortunately, there’s a workaround.

What you want is this:

<!-- Skip the deletion of any file within the ErrorLog directory -->
<MsDeploySkipRules Include="SkipErrorLogFolder1">
  <SkipAction>Delete</SkipAction>
  <ObjectName>filePath</ObjectName>
  <AbsolutePath>ErrorLog</AbsolutePath>
</MsDeploySkipRules>

In addition, you need to prevent VS from using the UI-task (which appears to contain a bug regarding the skip rules). You can do this by declaring the following in your wpp.targets or pubxml:

<PropertyGroup>
  <UseMsDeployExe>true</UseMsDeployExe>
</PropertyGroup>

I’ve tested this locally and I can confirm that it works as desired: the additional file is updated but no files in the directory are deleted.

Leave a Comment