2017-06-02 64 views
3

目標依賴關係圖中存在循環依賴項我試圖將Docker支持添加到現有的ASP.Net(Core)Web應用程序。在涉及目標「DockerBuildServiceReferences」

到目前爲止,我所做的只是右鍵單擊我的解決方案,然後單擊Add > Docker Support。當我再嘗試開始使用泊塢窗中,我得到以下錯誤調試:

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任何循環依賴,其實通過這僅僅是整個文件搜索

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

    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應用程序的核心在兩個地方提到並增加了docker的支持,它完美的工作。這導致我相信這個錯誤覆蓋了別的東西。

我使用Visual Studio 2017年和docker version輸出如下(有沒有什麼幫助的話):

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 

任何想法,將不勝感激!

回答

4

根據this threadthis answer,可如果你有Dockerfile和項目文件(.csproj)發生不是在同一個文件夾中這樣的情況,或者你在相同的解決方案文件(.sln項目文件(.csproj)夾。

您可能已經在同一個目錄中爲它創建瞭解決方案和啓動項目,這將導致docker循環引用。嘗試使用單獨的文件夾重新創建項目並重做所有步驟。

+1

我早點明白了,但忘了發佈答案。既然你張貼我會給你的代表:) – KidCode

+0

謝謝你:) – VMAtm