Delete bin and obj folders, in my case that helped. So many errors I am getting while trying to publish a .net maui app from VS and many of them I am solving by simply deleting the bin and obj folders.