MsBuild.exe MyProject.csproj /p:Configuration=Release /p:DebugType=None /p:Optimize=True /p:DeployOnBuild=true /p:PublishProfile=MyPublishProfile /p:VisualStudioVersion=16.0"
We used to run above command to build and published webapp using MsBuild.exe. This is working fine whenever we are using MsBuild packaged along with VS 2019. Path: C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin
However, as soon as we are using MsBuild that came along with VS2022, it is compiling project but not publishing.
Can anyone provide some light why publish is not working when running above command with MsBuild VS 2022?
Note: This project is targeting .Net framework 4.7.

