When we use dotnet cli to build a .NET Framework project we get the following error when including Esri.ArcGISRuntime library, error MSB4062: The "DeploymentTask" task could not be loaded from the assembly net461\Esri.ArcGISRuntime.LocalServices.BuildTasks.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 error is due to the dotnet cli using .NET Core and not .NET Framework for it's build tasks. The dotnet cli can not load the .NET Framework 4.6.1 dependent libraries for the Esri.ArcGISRuntime.LocalServices to complete the Esri DeploymentTask. Looking at the NuGet package(Esri.ArcGISRuntime.LocalServices), there is both a .NET Standard 2.0 and a .NET Framework 4.6.1 version of Esri.ArcGISRuntime.LocalServices.BuildTasks. I believe you can remove the .NET Framework 4.6.1 version and just use the .NET Standard version because .NET Standard 2.0 is compatible with .NET Framework 4.6.1 https://dotnet.microsoft.com/en-us/platform/dotnet-standard.
I have tested this myself by manually replacing the .NET Framework 4.6.1 Esri.ArcGISRuntime.LocalServices.BuildTasks library with the .NET Standard version and it successfully ran without errors and produced the expected results. I tested it also with Visual Studio 2022 and it was error free in both cases and produced the same results before and after the experiment of replacing the library. I believe this is the solution for this issue.
Can you please update the packages to resolve this error?
Thanks