Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Call Publish after Build in MSBuild

I am trying to call the Publish target every time I build my WPF app. I have tweaked the .csproj file to include this:

<Target Name="AfterBuild">
  <Message Text="Running AfterBuild..." />
  <MSBuild Projects="$(MSBuildProjectFullPath)" Properties="Configuration=$(Configuration); PublishDependsOn=" Targets="Publish" />
</Target>

When I run this from the command line, I see the message that it is 'Running AfterBuild...' but nothing happens. If I remove the '; PublishDependsOn=' from the Properties of the MSBuild task, I get a circular reference error.

What magic am I missing here?

like image 436
michaelkoss Avatar asked Oct 19 '25 08:10

michaelkoss


1 Answers

OK, I figured out how to do what I want to do. Instead of trying to explicitly call Publish in AfterBuild, I just added it to the DefaultTargets of the project. Now it calls Build then Publish.

<Project ToolsVersion="4.0" DefaultTargets="Build;Publish" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

like image 196
michaelkoss Avatar answered Oct 22 '25 05:10

michaelkoss



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!