aspnetcore: Circular dependency error when publishing webdeploy package using .net 5.0.300

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.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 21 (7 by maintainers)

Most upvoted comments

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

@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.

@vijayrkn I’ll try that tomorrow. Thank you very much!