Project management Practice "Five" automatic compilation and publishing site "Using Visual Studio with Source Control System to build and publish website automatically"

Source: Internet
Author: User
Tags robocopy robocopy gui

In the previous Tutorial project management practice "three" daily Build "Daily build using Cruisecontrol.net and MSBuild", we explained how to use Ccnet+msbuild to build the project, Today we explain how to use msbuild+webdeployment+robocopy to automatically compile and deploy an ASP.
Install the following three software first:

1.msbuild.community.tasks Download:
Http://msbuildtasks.tigris.org/files/documents/3383/28296/MSBuild.Community.Tasks.msi

Source:
Http://msbuildtasks.tigris.org/files/documents/3383/36642/MSBuild.Community.Tasks.v1.2.0.306.zip

2.WebDeployment Download:

For VS2005
Http://download.microsoft.com/download/9/4/9/9496adc4-574e-4043-bb70-bc841e27f13c/WebDeploymentSetup.msi

For VS2008 [RTW]
Http://download.microsoft.com/download/9/4/9/9496adc4-574e-4043-bb70-bc841e27f13c/WebDeploymentSetup.msi

3.Utility Spotlight Robocopy GUI Download: "After download, install after decompression, Vista does not install"
Http://download.microsoft.com/download/f/d/0/fd05def7-68a1-4f71-8546-25c359cc0842/UtilitySpotlight2006_11.exe

Once the installation is complete, the tutorial begins today.

We use the Startkit solution created in the previous tutorial as an example, with the following structure:

Right-click on the Web project Startkit shown and click Add Web Deployment Project ..., such as:

The following form pops up, entering the name of the deployment project and where the project will be placed, such as:

After clicking the OK button, the structure of the solution is as follows:

Today we will talk about the following two methods, the above steps, starting from here, the following steps are different.

Method One: Create a virtual directory using Webdeployment

Advantages: Easy to use

Cons: Powerful enough to deploy to virtual directories only

Right click on the deployment project and click on the property Pages in the menu, such as:

In the following form, click Complication on the left, and in the text box under output folder on the right, enter the output path of the compiled Web site file:

Then, click on the Deploment on the left, and on the right, select Create an IIS virtual directory for the output folder in front of the checkbox, in the following virtual directory Enter the name of the virtual directory in the text box under Name, Replace the checkbox in front of the existing virtual directory to determine if it is selected, as follows:

Click the OK button to compile the deployment project Startkit.csproj_deploy, after the compilation is successful, we open IIS and the virtual directory Startkit can be seen under the default Web site. OK, it's done!

Method Two: Use Webdeployment+msbuild+robocopy

Advantages: Powerful Features

Cons: Configuration is a bit cumbersome

This method does not need to configure the property Pages, right-click on the Startkit.csproj_deploy project file, and click Open Project file in the menu opens the deployment project files:

Modify the deployment project file to the following content:

1 <!--Microsoft Visual Studio Web Deployment Project http://go.microsoft.com/fwlink/?linkid=104956-->
2
3 <project toolsversion= "3.5" defaulttargets= "Build" xmlns= "http://schemas.microsoft.com/developer/msbuild/2003 ">
4 <PropertyGroup>
5 <configuration condition= "' $ (Configuration) ' = = '" >Debug</Configuration>
6 <platform condition= "' $ (Platform) ' = = '" >AnyCPU</Platform>
7 <ProductVersion>9.0.21022</ProductVersion>
8 <SchemaVersion>2.0</SchemaVersion>
9 <ProjectGuid>{00000000-0000-0000-0000-000000000000}</ProjectGuid>
Ten <sourcewebphysicalpath> \startkit</sourcewebphysicalpath>
<sourcewebproject>{96e1a089-3fbb-4909-94f6-172665994449}| Startkit\startkit.csproj</sourcewebproject>
<SourceWebVirtualPath>/StartKit.csproj</SourceWebVirtualPath>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<ProjectName>StartKit</ProjectName>
<Major>1</Major>
<Minor>0</Minor>
<Revision>0</Revision>
<VSSName>ttzhang</VSSName>
<VSSPassword>123456</VSSPassword>
<FtpName>anonymous</FtpName>
<FtpPassword>anonymous</FtpPassword>
<SmtpServerName>smtp.163.com</SmtpServerName>
<fromaddress>[email protected]</fromaddress>
<toaddress>[email protected]</toaddress>
<MailPassword>testmail</MailPassword>
</PropertyGroup>
<propertygroup condition= "' $ (Configuration) |$ (Platform) ' = = ' debug| AnyCPU ' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>.\Debug</OutputPath>
<EnableUpdateable>true</EnableUpdateable>
<UseMerge>true</UseMerge>
<SingleAssemblyName>StartKit_deploy</SingleAssemblyName>
</PropertyGroup>
<propertygroup condition= "' $ (Configuration) |$ (Platform) ' = = ' release| AnyCPU ' ">
<DebugSymbols>false</DebugSymbols>
<OutputPath>.\Release</OutputPath>
Panax Notoginseng <EnableUpdateable>true</EnableUpdateable>
<UseMerge>true</UseMerge>
<SingleAssemblyName>StartKit_deploy</SingleAssemblyName>
</PropertyGroup>
<ItemGroup>
</ItemGroup>
<!--the ItemGroup node below is optional, which is the same as the content in project file Startkit.csproj-
<ItemGroup>
<projectreference include= ". \bll\bll.csproj ">
<Project>{73A293A1-CDCC-4919-9B05-BA2531ADDB56}</Project>
<Name>BLL</Name>
</ProjectReference>
<projectreference include= ". \dal\dal.csproj ">
<Project>{AFF6077D-DD2D-48A0-BFAD-051BD67A6953}</Project>
Wuyi <Name>DAL</Name>
</ProjectReference>
<projectreference include= ". \ibll\ibll.csproj ">
<Project>{620770BB-7A27-4585-9B97-44EEE349121D}</Project>
<Name>IBLL</Name>
</ProjectReference>
<projectreference include= ". \model\model.csproj ">
<Project>{EA43EC2E-5890-4431-BD3E-5F6C090DEA3A}</Project>
<Name>Model</Name>
</ProjectReference>
</ItemGroup>
<!--introduced msbuildcommunitytasks-->
<import project= "$ (msbuildextensionspath) \msbuildcommunitytasks\msbuild.community.tasks.targets"/>
<!--Mail Send--
<!--<target name= "Emailtest" >
<message Text = "Mail sending" ></Message>
<mail smtpserver= "$ (smtpservername)"
subject= "Test"
Password= "$ (MailPassword)"
From = "$ (fromaddress)"
"$ (toaddress)"
Body= "This is a test of the Mail task."/>
</Target>-->
<!--backing up files to Ftp-->
<!--<target name= "Backup" dependsontargets= "Zip" >
<ftpupload username= "$ (ftpname)"
Password= "$ (FTPPassword)"
Localfile= "$ (zipfilename)"
Remoteuri= "ftp://192.168.1.2/sourcebackup/$ (zipfilename)"/>
<onerror executetargets= "Handleerrorbackup"/>
Bayi </Target>-->
<!--backup files to FTP failed send mail--
<!--<target name= "Handleerrorbackup" >
<message text= "Backup failed"/>
<mail smtpserver= "$ (smtpservername)"
To= "$ (toaddress)"
From= "$ (fromaddress)"
Subject= "$ (ProjectName) Build failed"
body= "Backup failure:could not finish backup."/>
</Target>-->
<!--compiling Projects--
<target name= "Buildprojectreferences" >
<msbuild projects= "@ (projectreference)" targets= "Build"/>
94 </Target>
<!--generate compressed Files--
<target name= "Zip" >
<!--time Format-
98 <time format= "YYYYMMDDHHMMSS" >
<output taskparameter= "Formattedtime" propertyname= "Builddate"/>
</Time>
101 <zip files= "@ (zipfiles)" Zipfilename= "Startkit v$ (Major)-$ (Minor)-$ (Revision)-$ (builddate). Zip"/>
102 </Target>
103 <!--copy Files--
104 <target name= "Copy" >
<!--stop IIS Services--
106 <servicecontroller servicename= "w3svc" action= "Stop"/>
107 <!--use Robocopy to copy the compiled file to the specified location/xd is the folder to ignore,/xf the file type to ignore-
108 <exec command= "Robocopy Debug c:\inetpub\startkit/mir/xd Fckeditor attachments. svn obj doc test/xf *.zip *.WDPR OJ *.user *.cs *.csproj "ignoreexitcode=" true "/>
109 <!--start the IIS service--
<servicecontroller servicename= "w3svc" action= "Start"/>
111 </Target>
<!--introduced webdeployment-->
113 <import project= "$ (Msbuildextensionspath) \microsoft\webdeployment\v9.0\microsoft.webdeployment.targets"/ >
<!--to modify your build process, add your task inside one of the targets below and uncomment it.
Similar extension points exist, see microsoft.webdeployment.targets.-->
<target name= "BeforeBuild" ></Target>
117 <target name= "Beforemerge" ></Target>
118 <target name= "Aftermerge" ></Target>
119 <target Name= "Afterbuild" >
<!--compile successfully, execute the following targets-->
121 <!-do not want to generate a zip file, you can note the following zip target-->
122 <calltarget targets= "Zip"/>
123 <calltarget targets= "Copy"/>
124 <!--<calltarget targets= "Emailtest"/>
<calltarget targets= "Backup"/>-->
126 </Target>
127 </Project>

After the successful compilation of the deployment project, open the C:\inetpub\StartKit folder and see if you have successfully copied the past? OK, I go to see, haha, the documents are all in, OK, success!

At this point, create a virtual directory or Web site on IIS that points to the directory specified in our deployment project. We have added the project to CCNet, so after each commit, MSBuild compiles the entire solution "of course compiling the deployment project", and if the compilation is successful, it will automatically deploy the latest program to our site. This will make the site and our development in real-time synchronization, this is not the only way to implement, there are many other ways to implement this function, you can discuss and exchange here.

Add:
Microsoft Build Engine (MSBuild) is the new build platform for Microsoft and Visual Studio. MSBuild is completely transparent about how to process and build software, enabling developers to organize and build products in a build lab environment where Visual Studio is not installed. With these tutorials, we can see the power of MSBuild, and if you want to understand more about MSBuild, see http://msdn.microsoft.com/zh-cn/library/ms171451.aspx here.

If you're unfamiliar with what I'm explaining, it's recommended that you look at this series of tutorials from the beginning: A series of project management practice tutorials.

Transferred from: http://www.cnblogs.com/ttzhang/archive/2008/11/10/1330321.html

Project management practices "Five" automatically compile and publish Web sites Using Visual Studio with Source Control System to build and publish website automatically "

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.