7

I have following target on csproj file using VS2012, i want to run "Publish" on the project once the build has finished.

This gives me following error "error MSB4006: There is a circular dependency in the target dependency graph involving target "AfterBuild""

<Target Name="AfterBuild">
  <Message Text="Running Publish..." Importance="high"/>
  <MSBuild Projects="$(ProjectPath)" Properties="DeployOnBuild=true;PublishProfile=WebDeploy;CreatePackageOnPublish=True;VisualStudioVersion=11.0"/>
</Target>

i have tried replacing the MSBuild step with

<Exec Command="$(MSBuildBinPath)\MSBuild C:\MyProj.csproj /p:DeployOnBuild=true /p:PublishProfile=WebDeploy /p:CreatePackageOnPublish=True /p:VisualStudioVersion=11.0" ContinueOnError="false" />

Doing above results in build/publish being run over and over.

i have tried naming target different, calling it via another target to no avail.

How can i run "Publish" on the project without getting into repeated cycles? can this be done in another way?

Anupam Yadav
  • 4,353
  • 4
  • 19
  • 20

2 Answers2

5

If you only build in Visual Studio, then putting something like this into your csproj file (at the end) will work:

 <Target Name="Deploy" AfterTargets="Build">
   <MSBuild
     Projects="$(ProjectPath)"
     Targets="WebPublish"
     Properties="PublishProfile=LocalDeploy"
   />
 </Target>

However, if you build with with MSBuild this will result in a circular dependency. I have not yet figured out a solution that will allow you to publish on build that works in both Visual Studio and MSBuild.

Micah Zoltu
  • 6,764
  • 5
  • 44
  • 72
0

Previously I was building with Visual Studio and TFS Server, which worked fine, but when i moved to GO-CD the following code caused a circular dependency creating packages.

 <Target Name="CopyLinkedContentFiles" AfterTargets="Build" DependsOnTargets="PipelinePreDeployCopyAllFilesToOneFolder">
<Copy SourceFiles="%(Content.Identity)"
      DestinationFiles="%(Content.Link)"
      SkipUnchangedFiles='true'
      OverwriteReadOnlyFiles='true'
      Condition="'%(Content.Link)' != ''" />

jonmeyer
  • 748
  • 8
  • 22