错误MSB4006:目标依赖关系图中涉及目标的循环依赖 [英] error MSB4006: There is a circular dependency in the target dependency graph involving target

查看:681
本文介绍了错误MSB4006:目标依赖关系图中涉及目标的循环依赖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用VS2012在csproj文件上设置了目标,我想在构建完成后在项目上运行发布".

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

这给了我以下错误错误MSB4006:目标依赖关系图中涉及目标"AfterBuild"的循环依赖"

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>

我尝试将MSBuild步骤替换为

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?

推荐答案

如果仅在Visual Studio中进行构建,则将这样的内容放入csproj文件中(最后)将起作用:

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>

但是,如果使用MSBuild进行构建,则会导致循环依赖.我还没有找到一种解决方案,可以让您发布在Visual Studio和MSBuild中都可以使用的版本.

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.

这篇关于错误MSB4006:目标依赖关系图中涉及目标的循环依赖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆