4

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?

michaelkoss
  • 516
  • 7
  • 19

1 Answers1

4

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">

michaelkoss
  • 516
  • 7
  • 19