Quick way to deploy web application to multiple environment.

Hello, Folks. It’s really interesting to know about MSBuild. Recently while working on one project we found that deploying Project Files on multiple environments consumes a lot of time. So we thought to take the help of MSBuild and deploy project files on live Server(s) automatically.
What is MSBuild?
MSBuild is Microsoft Build Engine for Visual Studio. MSBuild is completely transparent with regards to how to process and build software developed in Visual Studio.
Why MSBuild?
Initially from Visual studio we do publish via Publish Profile(s). MSBuild uses that publish profile and does deployment without the help of visual studio. It can reduce deployment time up to 70%.
This is the basic Dev environment which I have created to demonstrate you on Automatic Build. Developer can publish files to staging as well production Environments.
How MSBuild?
MSBuild command needs few command line options mainly MSBuild.exe, Visual Studio Project Solution File (.sln), and Publish Profile.
First of all, you need to get the path of MSBuild.exe in my case it is located at C:WindowsMicrosoft.NETFramework64v4.0.30319msbuild.exe
Create a new File and enter the below two MSBuild Commands. (Note: You need to change the path according to your project solution directory.)
"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe"
"C:\Users\npunjabi\Documents\Visual Studio 2013\Projects\DeveloperEnvironment\DeveloperEnvironment.sln"
/p:DeployOnBuild=true /p:PublishProfile "C:\Users\npunjabi\Documents\Visual Studio 2013\Projects\DeveloperEnvironment\DeveloperEnvironment\PropertiesPublish\ProfilesStaging.pubxml"
 
"C:WindowsMicrosoft.NETFramework64v4.0.30319msbuild.exe"
"C:\Users\npunjabi\Documents\Visual Studio 2013\Projects\DeveloperEnvironment\DeveloperEnvironment.sln"
/p:DeployOnBuild=true /p:PublishProfile"C:\Users\npunjabi\Documents\Visual Studio 2013\Projects\DeveloperEnvironment\DeveloperEnvironment\PropertiesPublish\ProfilesProduction.pubxml"
/p:DeployOnBuild=true – This will build the solution before deployment and will throw an error if build fails before it deploys the files.
Save this file with any name and provide extension as “.bat”.
Open Command Prompt in Administrator Mode and execute the MSBuild (.bat) file.
Note: If you are using SVN then before deployment you can also write the SVN Command which will update the solution. After that MSBuild.exe will build the code and then publish.
Please download this file for more user-friendly deployment file which will prompt the user for deployment whether to start deployment or not on particular servers. Thanks to Kiran Sir (http://kiranpatils.wordpress.com/) for helping me in creating deployment file.

To know more about Web Deploy: Click HereIf you have a better idea do share with us.

Have a nice Deployment! 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.