The target dependencies graph has a circular dependency including the target "DockerBuildServiceReferences"

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

Up to this point, all I have done is right click on my solution and then click Add > Docker Support

. When I 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".

      

I checked the file Microsoft.VisualStudio.Docker.Compose.targets

and I don't see any circular dependency involving DockerBuildServiceReferences

, actually looking at the entire file that it only mentions 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>

      

and

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

  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>

      

I also tried to create a new ASP.NET Core app from scratch and added docker support to it, it works great. This leads me to believe that this bug is covering something else.

I'm using Visual Studio 2017 and the output docker version

looks like this (if it 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!

+3


source to share


2 answers


According to this thread and this answer, such a situation may arise if you have Dockerfile

both the project file ( .csproj

) not in the same folder, or the solution project file ( .sln

) and ( .csproj

) in the same folder.



You may have created a solution project and run for it in the same directory, which will result in duplicate link in docker. Try to re-create the project with a separate folder and repeat all steps.

+4


source


For anyone getting this error and @VMAtm's answer is not allowed. This can also happen if you run migration commands in your solution folder, a level above your .csproj and dockerfile. Make sure you are in the project folder when starting the migration.



0


source







All Articles