0

Publishing in release configuration gives this error:

Microsoft.Bcl.Build.targets(97,5): error MSB4062: The "EnsureBindingRedirects" task could not be loaded from the assembly ...\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.Tasks.dll.

Could not load file or assembly 'Microsoft.Build.Utilities.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

The system cannot find the file specified. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask

This is my publish command:

dotnet publish  .\MyProject.csproj --runtime win10-x64
--self-contained --configuration release
  • If I omit the configuration parameter the build is successful.
  • Building with Visual Studio (msbuld) works with debug or release configurations.

This is a .Net 5 project that references projects that use .Net framework 4.7.2 projects.

Don Chambers
  • 3,798
  • 9
  • 33
  • 74
  • Did you try to restore the project via CLI before the publish command? You could try updating your dependencies or clearing the cached packages first then doing a restore. Also, if you remove the reference to this package will the project compile successfully? – HMZ Oct 04 '21 at 19:31
  • The publish should do a restore, but I also did it explicitly and still get the problem. I can't delete the package. It's part of the old framework code, which other use. In order to remove it, I had to remove Microsoft.aspnet.webapi.client and Microsoft.net.http, and then the project wouldn't build. – Don Chambers Oct 04 '21 at 20:43

0 Answers0