question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Circular dependency error when publishing webdeploy package using .net 5.0.300

See original GitHub issue

I am getting the following error when I try and generate a webdeploy package using .net 5: C:\Program

Files\dotnet\sdk\5.0.300\Sdks\Microsoft.NET.Sdk.Publish\targets\CopyTargets\Microsoft.NET.Sdk.Publish.CopyFiles.targets(80,5): error MSB4006: There is a circular dependency in the target dependency graph involving target "Publish". Since "_CopyAspNetCoreFilesToIntermediateOutputPath" has "DependsOn" dependence on "Publish", the circular is "Publish<-_CopyAspNetCoreFilesToIntermediateOutputPath<-CorePublish<-DotNetPublish<-_PublishBuildAlternative<-Publish"

Repro steps: dotnet new mvc -n mvcApp cd mvcApp dotnet restore dotnet publish /p:WebDeployMethod=package /p:DeployOnBuild=true;

expected result: Web Deploy Package produced

actual result: Microsoft ® Build Engine version 16.10.0+4242f381a for .NET Copyright © Microsoft Corporation. All rights reserved.

Determining projects to restore… All projects are up-to-date for restore. mvcApp -> C:\Temp\mvcApp\bin\Debug\net5.0\mvcApp.dll mvcApp -> C:\Temp\mvcApp\bin\Debug\net5.0\mvcApp.Views.dll C:\Program Files\dotnet\sdk\5.0.300\Sdks\Microsoft.NET.Sdk.Publish\targets\CopyTargets\Microsoft.NET.Sdk.Publish.CopyFiles.targets(80,5): error MSB4006: There is a circular dependency in the target dependency graph involving target “Publish”. Since “_CopyAspNetCoreFilesToIntermediateOutputPath” has “DependsOn” dependence on “Publish”, the circular is “Publish<-_CopyAspNetCoreFilesToIntermediateOutputPath<-CorePublish<-DotNetPublish<-_PublishBuildAlternative<-Publish”. [C:\Temp\mvcApp\mvcApp.csproj]

This seems to be similar to https://github.com/dotnet/sdk/issues/16474 but I’m not using Visual Studio. dotnet clean doesn’t seem to help.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:21 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
dsplaistedcommented, Sep 9, 2021

OK, I’ve filed #36343 for the PublishDir / PublishUrl issue.

2reactions
vijayrkncommented, Aug 11, 2021

@Kaelum - If you feel uncomfortable replacing the property, you can always add this as an additional property

		<publishUrl>..\.publish\ACME.debug.linux-x64\</publishUrl>
		<PublishDir>$(PublishUrl)</PublishDir>

With this both CLI & VS will work happily.

I agree that having the difference in the property name can be confusing. The reason VS still uses publishUrl is because VS has always honored this property even before the dotnet cli tools were ever built. Web publishing has been a concept in VS before the CLI tool era.

Having said that, I can see how dotnet publish honoring this additional property can reduce the confusion for existing profiles created from VS or otherwise.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Circular dependency error when publishing webdeploy ...
I am getting the following error when I try and generate a webdeploy package using .net 5: C:\Program ...
Read more >
c# - error MSB4006: There is a circular dependency in the ...
I have following target on csproj file using VS2012, i want to run "Publish" on the project once the build has finished. This...
Read more >
There is a circular dependency in the target ...
We are using Code first asp.net application (.net frame work 4.7.2), and able to run update-database command from visual studio.
Read more >
Cannot publish ASP NET Core 3.1 API project. Circular ...
Running Publish in Rider causes a restore to run and then publish fails with a circular dependency error on Core project (which doesn't...
Read more >
VS 2022 image cannot build hello world program
Sdk.Publish.CopyFiles.targets(80,5): error MSB4006: There is a circular dependency in the target dependency graph involving target "Publish".
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found