use cmd to run on publish ..net core code example
Example: msbuild publish to folder command line .net
msbuild mysln.sln /p:DeployOnBuild=true /p:PublishProfile=<profile-name>
msbuild mysln.sln /p:DeployOnBuild=true /p:PublishProfile=<profile-name>