gpt4 book ai didi

c# - 错误 MSB4006 : There is a circular dependency in the target dependency graph involving target

转载 作者:行者123 更新时间:2023-11-30 15:29:58 25 4
gpt4 key购买 nike

我在使用 VS2012 的 csproj 文件上有以下目标,我想在构建完成后在项目上运行“发布”。

这给了我以下错误“错误 MSB4006:目标依赖关系图中存在涉及目标“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 步骤
<Exec Command="$(MSBuildBinPath)\MSBuild C:\MyProj.csproj /p:DeployOnBuild=true /p:PublishProfile=WebDeploy /p:CreatePackageOnPublish=True /p:VisualStudioVersion=11.0" ContinueOnError="false" />

执行上述操作会导致构建/发布被一遍又一遍地运行。

我试过命名目标不同,通过另一个目标调用它无济于事。

如何在不进入重复循环的情况下对项目运行“发布”?这可以用另一种方式完成吗?

最佳答案

如果您只在 Visual Studio 中构建,那么将类似这样的内容放入您的 csproj 文件(最后)将起作用:

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

但是,如果您使用 MSBuild 构建,这将导致循环依赖。我还没有想出一个解决方案,让您可以在 Visual Studio 和 MSBuild 中发布构建版本。

关于c# - 错误 MSB4006 : There is a circular dependency in the target dependency graph involving target,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22933314/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com