Your task is probably on .NET Core, meanwhile you're building with the net472-targeted MSBuild.exe. To fix this: either switch from using MSBuild.exe to using dotnet build, or change the TargetFramework of your task.
- Set the
TargetFrameworkproperty in your task's project tonet472.
OR
- Use
dotnet build <yourproj>, instead ofmsbuild <yourproj>