在目标依赖关系图中存在涉及目标“ DockerBuildServiceReferences”的循环依赖关系。 [英] There is a circular dependency in the target dependency graph involving target "DockerBuildServiceReferences"

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

问题描述

我正在尝试将docker支持添加到现有的ASP.Net(核心)Web应用程序中。

I'm trying to add docker support to an existing ASP.Net (Core) web application.

到目前为止,我所做的只是右键单击我的解决方案,然后单击添加> Docker支持。然后,当我尝试使用docker开始调试时,出现以下错误:

Up to this point, all I've done is right click my solution and then clicked on Add > Docker Support. When I then try to start debugging using docker I get the following error:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Microsoft\VisualStudio\v15.0\Docker\Microsoft.VisualStudio.Docker.Compose.targets(170,5): error MSB4006: There is a circular dependency in the target dependency graph involving target "DockerBuildServiceReferences".

我已经检查了 Microsoft.VisualStudio.Docker.Compose.targets 文件,我看不到任何涉及 DockerBuildServiceReferences 的循环依赖项,实际上,在整个文件中进行搜索的地方只有两个地方提到了它:

I've checked the Microsoft.VisualStudio.Docker.Compose.targets file and I can't see any circular dependency involving DockerBuildServiceReferences, in fact searching through the entire file it's only mentioned in two places:

  <!--
  ***********************************************************************************************

  Docker Compose Project Targets

  ***********************************************************************************************
  -->

  <UsingTask TaskName="CleanWorkspace" AssemblyFile="$(DockerBuildTasksAssembly)" />
  <UsingTask TaskName="EnsureMsVsMonExists" AssemblyFile="$(DockerBuildTasksAssembly)" />
  <UsingTask TaskName="EnsureVsDbgExists" AssemblyFile="$(DockerBuildTasksAssembly)" />
  <UsingTask TaskName="GetServiceReferences" AssemblyFile="$(DockerBuildTasksAssembly)" />
  <UsingTask TaskName="PrepareForBuild" AssemblyFile="$(DockerBuildTasksAssembly)" />
  <UsingTask TaskName="PrepareForLaunch" AssemblyFile="$(DockerBuildTasksAssembly)" />

  <PropertyGroup>
    <BuildDependsOn>
      DockerSetDevelopmentMode;
      DockerPrepareForBuild;
      DockerGetServiceReferences;
      DockerBuildServiceReferences;
      $(BuildDependsOn);
      DockerComposeBuild;
      DockerPrepareForLaunch;
    </BuildDependsOn>
    <CleanDependsOn>
      DockerSetDevelopmentMode;
      DockerCleanWorkspace;
      $(CleanDependsOn);
      DockerGetServiceReferences;
      DockerCleanServiceReferences;
    </CleanDependsOn>
  </PropertyGroup>

  <PropertyGroup>
    <DockerComposeProjectPath>$(MSBuildProjectFullPath)</DockerComposeProjectPath>
  </PropertyGroup>

并且:

  <!--
  ***********************************************************************************************

  TARGET : DockerBuildServiceReferences

  ***********************************************************************************************
  -->

  <Target Name="DockerBuildServiceReferences">
    <PropertyGroup>
      <DockerServiceReferenceTarget Condition=" '$(DockerDevelopmentMode)' == 'Regular' ">DockerPackageService</DockerServiceReferenceTarget>
      <DockerServiceReferenceTarget Condition=" '$(DockerServiceReferenceTarget)' == '' ">Build</DockerServiceReferenceTarget>
    </PropertyGroup>
    <MSBuild Projects="@(DockerServiceReference)"
             Targets="$(DockerServiceReferenceTarget)"
             Properties="Configuration=$(Configuration);Platform=$(Platform);BuildingInsideVisualStudio=false"
             Condition=" '@(DockerServiceReference)' != '' " />
  </Target>

我还尝试从头开始创建新的ASP.NET Core应用,并为此添加了docker支持,它运作完美。

I've also tried creating a new ASP.NET Core app from scratch and added docker support to that, it works perfectly. Which leads me to believe this error is covering for something else.

我正在使用Visual Studio 2017和 docker版本如下(如果有帮助的话):

I'm using Visual Studio 2017 and the output of docker version is as follows (if that helps at all):

Client:
 Version:      17.05.0-ce-rc1
 API version:  1.27 (downgraded from 1.29)
 Go version:   go1.7.5
 Git commit:   2878a85
 Built:        Wed Apr 12 19:43:25 2017
 OS/Arch:      windows/amd64

Server:
 Version:      17.03.1-ce
 API version:  1.27 (minimum version 1.12)
 Go version:   go1.7.5
 Git commit:   c6d412e
 Built:        Fri Mar 24 00:00:50 2017
 OS/Arch:      linux/amd64
 Experimental: true

任何想法都将不胜感激!

Any ideas would be greatly appreciated!

推荐答案

根据这个线程此答案,如果您有 Dockerfile 和项目文件( .csproj )不在同一文件夹中,或者您有解决方案文件( .sln 项目文件( .csproj )在同一文件夹中。

According this thread and this answer, such situation may occur if you have Dockerfile and the project file (.csproj) not in the same folder, or you have a solution file (.sln) and project file (.csproj) in the same folder.

您可能已经在同一目录中为其创建了解决方案和启动项目,这将导致Docker循环引用。尝试使用单独的文件夹重新创建项目,然后重做所有步骤。

You've probably created a solution and startup project for it in the same directory, which will lead to docker circular reference. Try to re-create your project with separate folder and redo all the steps.

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

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