getting this error during the publish task of my pipeline to deploy a webapp : D:\a\1\s\LDTUTMVMAutoApp.csproj(263,3): error MSB4019: The imported project "C:\hostedtoolcache\windows\dotnet\sdk\5.0.300\Microsoft\VisualStudio\v16.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the expression in the Import declaration "C:\hostedtoolcache\windows\dotnet\sdk\5.0.300\Microsoft\VisualStudio\v16.0\WebApplications\Microsoft.WebApplication.targets" is correct, and that the file exists on disk.
I assume it might have something to do with the imports in my *.csproj file?
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
This is due to the wrong choice of your build task. Your project is Web app based on .net framework instead of .net core, so the dotnet build task used cannot find the web target file corresponding to the web app in the .net core directory.
You can use msbuild task or visual stuido build task instead.