In this example solution (Visual Studio Community 2019 Version), I have created 2 Projects with MVC Application and an API project.
Note: Both Projects are created on .NET framework 4.8, However, I have tested with .NET Core 6.0 Projects created using Visual Studio Professional/Community versions successfully.
Here is my Project Structure for the demo.
Option 1 - Create a publish profile for the project. DevOpsProfile.pubxml
<project> <propertygroup> <deleteexistingfiles>True</deleteexistingfiles> <excludeapp_data>False</excludeapp_data> <launchsiteafterpublish>True</launchsiteafterpublish> <lastusedbuildconfiguration>Release</lastusedbuildconfiguration> <lastusedplatform>Any CPU</lastusedplatform> <publishprovider>FileSystem</publishprovider> <publishurl>bin\Release</publishurl> <webpublishmethod>FileSystem</webpublishmethod> <siteurltolaunchafterpublish> </siteurltolaunchafterpublish></propertygroup> </project>
"C:\Program Files\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe" ".\DevOpsApplication.sln" /p:Configuration="Release" /t:Rebuild /t:Restore /p:DeployOnBuild=true /p:PublishProfile="DevOpsProfile"
Option 2 - Without using a publish profile, define all the properties inline with MsBuild.exe
"C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe" ^ ".\DevOpsApplication.sln" ^ /t:Rebuild ^ /t:Restore ^ /p:Configuration=Release ^ /p:DeployOnBuild=True ^ /p:DeployDefaultTarget=WebPublish ^ /p:WebPublishMethod=FileSystem ^ /p:DeleteExistingFiles=True ^ /p:PublishUrl="bin\Release"
Output folders
MVC Web Project Artifacts using MsBuild.exe
Api Project Artifacts using MsBuild.exe
No comments:
Post a Comment