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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With