title: How to execute a PowerShell script only before a web deploy Publish task in VS 2012?
body: <p>Currently I have a post-build event configured in my web project using Visual Studio 2012 like this:</p>
  
  <p><img src="https://i.stack.imgur.com/S8fcC.png" alt="enter image description here"></p>
  
  <p>This basically calls a <a href="https://stackoverflow.com/q/12199409/114029">PowerShell script</a> to add a copyright notice to every .cs file.</p>
  
  <p>What I'd like to do is to execute this powershell script <strong><em>only before</em></strong> Publishing the web app to the remote server. Doing so I won't experience a delay every time I need to debug the project. Do you know of any way of accomplishing this?</p>
  
  <hr>
  
  <p>According to <a href="https://stackoverflow.com/a/12920499/114029">Sayed's answer</a>, I customized a specific publish profile and added this:</p>
  
  <pre><code>&lt;PipelineDependsOn&gt;
    CustomBeforePublish;
    $(PipelineDependsOn);
  &lt;/PipelineDependsOn&gt;
  &lt;/PropertyGroup&gt;
  &lt;Target Name="CustomBeforePublish"&gt;
  &lt;Message Text="******* CustomBeforePublish *******" Importance="high" /&gt;
  &lt;Exec Command="powershell.exe -file &amp;quot;$(ProjectDir)\Copyright.ps1&amp;quot;" /&gt;
  &lt;/Target&gt;
  </code></pre>