Deploy .Net project automatically with MsBuild and MsDeploy (0)
I will use a example of my project to show how to use MS Build and MS Deploy in a real project and situation.
First of all, I should put the URLs of MS Build and MS Deploy instruction came from MSDN here:
MS Build: https://msdn.microsoft.com/en-us//library/dd393574.aspx
MS Deploy: https://technet.microsoft.com/en-us/library/dd569106%28WS.10%29.aspx
Second, download the latest version of MS Build in Visual Studio official web site and MS Deploy in IIS official web site, here is the address:
Visual Studio: https://www.visualstudio.com/en-us/downloads/download-visual-studio-vs.aspx
IIS: http://www.iis.net/downloads/microsoft/web-deploy
After MS Build and MS Deploy is installed, the MS Build contents are in the folder ‘C:\Windows\Microsoft.NET 'and the MS Deploy contents are in the folder ‘C:\Program Files (x86)\IIS\Microsoft Web Deploy V3’
Need have some concepts about MS Build and MS Deploy, otherwise it would be difficult to make sense of what I will show you below.
Some questions
In my project solution, I have three individual projects which provide functionality in different layer for the whole application. So I have three project files with the file extension(.csproj) need to be used in auto-deployment process. The three projects files are VRent.csproj, VRentDataAccess.csproj and ScheduleJob.csproj. Each of them has own configuration file contains many custom parameters or attributes that are used in the application for some reasons need be changed dynamically, for example WCF server/client endpoint address.
So the 1st question is how to change parameter values in configuration files dynamically during the process of building
When the parameter values could be changed, I want to build the project. But before building the project, I should archive the old version to a particular folder from IIS Web site or abstract application, whatever.
So the 2rd question is how to archive Web from IIS to physical folder
And then, I should build the project and package it for preparing to deploy it to IIS
So the 3rd question is how to build project with MS Build
After the package is prepared, I should deploy it to IIS. Developers or testers are likely to using the application which have already deployed in IIS at that moment I want to deploy a new one with higher version. In the case, the memory or thread of the application occupied is not be released by IIS. So if I try to deploy a new version, error would happen as the inaccessible application.
So the 4th question is how to recycle a particular application before deploying a new version to avoid the error regarding permission
Finally, I should deploy the project to IIS without any block
the 5th question is how to deploy project with MS Deploy
According to the five questions I mentioned above, I make five steps to finish the presentation as these questions' order and I will give a detailed description each of the question in the later section