title: MSDeploy skip rules when using MSBuild PublishProfile with Visual Studio 2012
body: <p>I'm trying to use WebDeploy to publish a website using custom MSDeploy skip rules and a publish profile saved in Visual Studio 2012.</p>
  
  <p>I have the publish profile working from the command line, but the skip rule to skip deleting a folder isn't working. </p>
  
  <p>I have an <code>ErrorLog</code> subfolder in my web app with a <code>web.config</code> file inside it to set the proper folder permissions. Without any skip rules, the <code>ErrorLog</code> folder and <code>web.config</code> file are published normally, but all existing error log files in the folder on the server are deleted on publish.</p>
  
  <hr>
  
  <p><strong>Error with <code>&lt;SkipAction&gt;Delete&lt;/SkipAction&gt;</code></strong></p>
  
  <p>When I add a custom skip rule to my <code>wpp.targets</code> file, the skip rule is no longer accepting a value for the <code>&lt;SkipAction&gt;</code> element. If I set <code>&lt;SkipAction&gt;Delete&lt;/SkipAction&gt;</code>, I get the following error:</p>
  
  <pre><code>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web\Microsoft.Web.Publishing.targets(4377,5): error : Web deployment task failed. (Unrecognized skip directive 'skipaction'. Must be one of the following: "objectName," "keyAttribute," "absolutePath," "xPath," "attributes.&lt;name&gt;.") [C:\inetpub\wwwroot\My.Website\My.Website\My.Website.csproj]
  </code></pre>
  
  <p>If I simply omit the <code>&lt;SkipAction&gt;</code> element, the <code>ErrorLog</code> folder is deleted when it would normally be published.</p>
  
  <p>If I set <code>&lt;SkipAction&gt;&lt;/SkipAction&gt;</code>, again, the <code>ErrorLog</code> folder is deleted on publish.</p>
  
  <p>If I set <code>&lt;KeyAttribute&gt;Delete&lt;/KeyAttribute&gt;</code>, then <code>ErrorLog</code> and the <code>web.config</code> file are published normally.</p>
  
  <p>My understanding is that in order to use custom skip rules, you need to call MSBuild from the command line instead of publishing from within VS 2012. I'd still like to use my saved publishing profiles, however, and I understand that's now possible as of VS 2012.</p>
  
  <hr>
  
  <p><strong>My MSBuild command line:</strong></p>
  
  <pre><code>C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe My.Website.sln /p:Configuration=Release;DeployOnBuild=true;PublishProfile="Test Server - Web Deploy"
  </code></pre>
  
  <hr>
  
  <p><strong>My.Website.wpp.targets:</strong></p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt;
    &lt;PropertyGroup&gt;
      &lt;AfterAddIisSettingAndFileContentsToSourceManifest&gt;AddCustomSkipRules&lt;/AfterAddIisSettingAndFileContentsToSourceManifest&gt;
    &lt;/PropertyGroup&gt;
  
    &lt;Target Name="AddCustomSkipRules"&gt;
      &lt;Message Text="Adding Custom Skip Rules" /&gt;
      &lt;ItemGroup&gt;
        &lt;MsDeploySkipRules Include="SkipErrorLogFolder1"&gt;
          &lt;SkipAction&gt;&lt;/SkipAction&gt;
          &lt;KeyAttribute&gt;Delete&lt;/KeyAttribute&gt;
          &lt;ObjectName&gt;dirPath&lt;/ObjectName&gt;
          &lt;AbsolutePath&gt;$(_Escaped_WPPAllFilesInSingleFolder)\\ErrorLog$&lt;/AbsolutePath&gt;
          &lt;XPath&gt;&lt;/XPath&gt;
        &lt;/MsDeploySkipRules&gt;
      &lt;/ItemGroup&gt;
    &lt;/Target&gt;
  &lt;/Project&gt;
  </code></pre>
  
  <hr>
  
  <p><strong>My MSBuild output showing the custom skip rule, but still deleting the files:</strong></p>
  
  <pre><code>GenerateMsdeployManifestFiles:
    Generate source manifest file for Web Deploy package/publish ...
  AddCustomSkipRules:
    Adding Custom Skip Rules
  MSDeployPublish:
    Start Web Deploy Publish the Application/package to http://testserver.domain.com/MSDEPLOYAGENTSERVICE ...
    Starting Web deployment task from source: manifest(C:\inetpub\wwwroot\My.Website\My.Website\obj\Release\Package\My.Website.SourceManifest.xml) to Destination: auto().
    Deleting filePath (MyWeb/ErrorLog\test.txt).
    Updating setAcl (MyWeb/).
    Updating setAcl (MyWeb/).
    Updating filePath (MyWeb/ErrorLog\Web.config).
    Updating filePath (MyWeb/Web.config).
    Updating setAcl (MyWeb/).
    Updating setAcl (MyWeb/).
    Successfully executed Web deployment task.
    Publish is successfully deployed.
  </code></pre>