2

I need to execute my power shell script after my program has published (i use the ClickOnce). For this, I add into my .csproj file:

<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Target Name="AfterPublish">
      <Exec Command="powershell.exe -Command &quot;&amp; { .\Deploy.ps1 }&quot;" />
  </Target>
...
</Project>

But the script executes before publish. It is absolutely necessary that the script execute after the program has finished publishing because script copies the resulting published files from my computer to Azure storage.

l1pton17
  • 444
  • 4
  • 16
  • Please have a look at this answer: [Post build event execute powershell](http://stackoverflow.com/questions/6500320/post-build-event-execute-powershell) – Claudio P Dec 23 '14 at 13:23
  • yes, i looked at this answer before post a question. in there topic powershell scipt executed after build, but i need, that script executed after PUBLISH. – l1pton17 Dec 23 '14 at 13:25
  • After change Name to AfterPublish script sctarted executed, but it executed before build started! How can i fix it? – l1pton17 Dec 23 '14 at 14:57

1 Answers1

0

You should attach it to WebDeployPublish traget. Have a look at your typo (AffterPublish). You could try this:

<Target Name="AfterPublish" AfterTargets="MSDeployPublish">
   [DO YOUR STUFF]
</Target>

Hope it helps

Claudio P
  • 2,133
  • 3
  • 25
  • 45