Reputation: 211
We are trying get Team Foundation Server 2017 to automate a build, and thus far we have always just used Visual Studio to build and publish, but now having Team Foundation Server do it we are running into an issue with circular dependencies.
We are using the Visual Studio build step.
There are multiple projects in the solution (.sln).
The project blows up on references to two other projects which do not reference this project directly or indirectly.
I've looked all over for an article describing how to track down this circular reference, but everything I have found so far talks about MSBuild or it's having an issue with target "Publish" or something other than "Build".
Error:
[error]D:\VS2017\MSBuild\Microsoft\VisualStudio\v15.0\Web\Microsoft.Web.Publishing.targets(1279,11):
Error MSB4006: There is a circular dependency in the target dependency graph involving target "Build".
Project "D:\Agent\2.112.0_work\2\s\SLNNAME\SLNNAME.sln" (1) is building "D:\Agent\2.112.0_work\2\s\SLNNAME\Inventory\Inventory.csproj" (17) on node 1 (default targets).
D:\VS2017\MSBuild\Microsoft\VisualStudio\v15.0\Web\Microsoft.Web.Publishing.targets(1279,11): error MSB4006: There is a circular dependency in the target dependency graph involving target "Build".
[D:\Agent\2.112.0_work\2\s\SLNNAME\Inventory\Inventory.csproj]
Done Building Project "D:\Agent\2.112.0_work\2\s\SLNNAME\Inventory\Inventory.csproj" (default targets) -- FAILED.
Done Building Project "D:\Agent\2.112.0_work\2\s\SLNNAME\SLNNAME.sln" (default targets) -- FAILED.
Build FAILED.
Here are my build targets in the .sln file:
<Target Name="OverrideAppConfigWithTargetPath">
<ItemGroup>
<AppConfigWithTargetPath Remove="@(AppConfigWithTargetPath)" />
<AppConfigWithTargetPath Include="$(TransformedConfig)" Condition="'$(TransformedConfig)'!=''">
<TargetPath>$(TargetFileName).config</TargetPath>
</AppConfigWithTargetPath>
</ItemGroup>
</Target>
<Target Name="CopyTransformedConfig" Condition="'$(TargetName)' != ''">
<Copy Condition="Exists('$(TransformedConfig)')" SourceFiles="$(TransformedConfig)" DestinationFiles="$(OutputPath)$(TargetName)$(TargetExt).config" />
<Copy Condition="Exists('$(TransformedConfig)') And '$(TargetExt)' == '.exe'" SourceFiles="$(TransformedConfig)" DestinationFiles="$(OutputPath)$(TargetName).vshost.exe.config" />
</Target>
<Target Name="AfterPublish">
<PropertyGroup>
<DeployedConfig>$(_DeploymentApplicationDir)$(TargetName)$(TargetExt).config$(_DeploymentFileMappingExtension)</DeployedConfig>
</PropertyGroup>
<Copy Condition="Exists('$(DeployedConfig)')" SourceFiles="$(TransformedConfig)" DestinationFiles="$(DeployedConfig)" />
</Target>
<Import Project="..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets" Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets'))" />
</Target>
Upvotes: 3
Views: 10359
Reputation: 17
This error happens when:
These dependencies are the dependencies you’ll get if you right-click a project in Solution Explorer, choose Project Dependencies, and start checking projects. This is usually unnecessary as project dependencies can be inferred from the References. The fix is to open the SLN file in your favorite text editor, and search for sections like this:
Project("{AAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyProjectName", "MyProjectName\MyProjectName.csproj", "{B10E1FCF-DFBA-44A8-830F-6F3B54DFA7CB}"
ProjectSection(ProjectDependencies) = postProject
{B9E9F8CE-A607-4A6C-97F7-2BD439122F89} = {B9E9F8CE-A607-4A6C-97F7-2BD439122F89}
EndProjectSection
EndProject
Just delete the entire section, so your Project node looks like this:
Project("{AAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyProjectName", "MyProjectName\MyProjectName.csproj", "{B10E1FCF-DFBA-44A8-830F-6F3B54DFA7CB}"
EndProject
Now you should be able to use MSBuild successfully.
Upvotes: -1
Reputation: 8404
I ran into the very same issue.
This helped me:
https://community.embarcadero.com/blogs/entry/how-to-fix-msbuild-error-msb4006-38787
I had added a post build to a project with the last checkin, and somehow, project dependencies were added to the .sln, too.
It built fine in VS, but not on TFS build.
I just undid the last changes to the solution (see link, remove the new dependency group).
ProjectSection(ProjectDependencies) = postProject
{9D6D8692-16DD-452C-9D08-1498B3D51A9F} = {9D6D8692-16DD-452C-9D08-1498B3D51A9F}
{9BE28BBA-B3F6-4076-B989-3B1B48DACF38} = {9BE28BBA-B3F6-4076-B989-3B1B48DACF38}
EndProjectSection
Don't know if that fixes your problem, during googling I found many similar issues with rather different causes/solutions.
Upvotes: 0