Cause: Currently our team uses Visual Studio 2013 to develop ASP, use tfs2013 for source control, manually publish the project packages every morning, copy the old files to the site folder of the test server, and publish the system in this way, even several times a day. Low-efficiency effort. Objective: To automate the publishing of ASP. NET sites with TFS, without human intervention, to be able to check in or schedule codeASP. NET Project Publishing. Results: Initial successful automatic release of the system configuration process:
- Client: Visual Studio 2013 development environment, ability to connect to source server (TFS 2013) Normally, get checked in ASP. NET project Source code
- Source server (TFS 2013)
- ASP. NET Server (IIS), with normal access, ability to use project packages to overwrite old files under Site folders, and to access them normally
- Configure Web Deploy Publishing
- IIS installation Configuration "Management Services"
Refer to the second part of this article: Graphic details remote deployment ASP. NET MVC 5 Project
- To download and install Web deploy, it is recommended that you use "Full installation." Note the installation order: "Web Deploy" after "Manage service", if the reverse, "Web deploy" will need to run the Setup program to use the modification function, and finally do "full installation".
- Test Web Deploy, test Web Deploy with Https://IP:8172/MsDeploy.axd, and if the User name Password dialog box pops up, the Web deploy installation succeeds. You don't have to wait to see the results.
- You successfully publish an ASP. asp. NET site to IIS by using Web Deploy publishing in the Visual Studio. ASP. NET project.
Refer to the third part of this article: text-to-detail remote deployment of the ASP. NET MVC 5 project.
This step is critical and is the cornerstone of the continuation of the next work. Note: Pay close attention to publishing profiles in Pubxml, which is the key to publishing the system.
- Add and test the configuration of files that need to be added and excluded when publishing.
For example, exclude the Web. config file and the Fonts folder:
<ExcludeFilesFromDeployment>
Web. config
</ExcludeFilesFromDeployment>
<ExcludeFoldersFromDeployment>
Fonts
</ExcludeFoldersFromDeployment>
The full Pubxml file is as follows:
<?xml version= "1.0" encoding= "Utf-8"?>
<!--
The Publish/package process for your WEB project will use this file. You can edit this MSBuild file by
The behavior from which the process is defined. To learn more about this, please visit http://go.microsoft.com/fwlink/?LinkID=208121.
-
<project toolsversion= "4.0" xmlns= "http://schemas.microsoft.com/developer/msbuild/2003" >
<PropertyGroup>
<WebPublishMethod>MSDeploy</WebPublishMethod>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<lastusedplatform>any cpu</lastusedplatform>
<SiteUrlToLaunchAfterPublish>http://192.168.61.131:81</SiteUrlToLaunchAfterPublish>
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<MSDeployServiceURL>192.168.61.131</MSDeployServiceURL>
<DeployIisAppPath>test1</DeployIisAppPath>
<remotesitephysicalpath/>
<SkipExtraFilesOnServer>True</SkipExtraFilesOnServer>
<MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
<EnableMSDeployBackup>True</EnableMSDeployBackup>
<UserName>iispeiyu</UserName>
<_SavePWD>True</_SavePWD>
<PublishDatabaseSettings>
<objects xmlns= "" >
<objectgroup name= "DefaultConnection" order= "1" enabled= "False" >
<destination path= ""/>
<object type= "DBDACFX" >
<presource path= "Data source= (LocalDb) \v11.0; attachdbfilename=| Datadirectory|\aspnet-webapplication4-0798e767-bdbb-48c0-b104-8b9c14b6e40c.mdf;initial Catalog= aspnet-webapplication4-0798e767-bdbb-48c0-b104-8b9c14b6e40c;integrated security=true "includeData=" False "/>
<source path= "$ (intermediateoutputpath) Autoscripts\defaultconnection_incrementalschemaonly.dacpac" dacpacaction= "Deploy"/>
</Object>
<updatefrom type= "Web. config" >
<source matchvalue= "Data source= (LocalDb) \v11.0;initial catalog= Aspnet-webapplication4-0798e767-bdbb-48c0-b104-8b9c14b6e40c;integrated Security=sspi; attachdbfilename=| Datadirectory|\aspnet-webapplication4-0798e767-bdbb-48c0-b104-8b9c14b6e40c.mdf "MatchAttributes=" $ ( updatefromconnectionstringattributes) "/>
</UpdateFrom>
</ObjectGroup>
</Objects>
</PublishDatabaseSettings>
<!--drain some files or folders--
<ExcludeFilesFromDeployment>
Web. config
</ExcludeFilesFromDeployment>
<ExcludeFoldersFromDeployment>
Fonts
</ExcludeFoldersFromDeployment>
</PropertyGroup>
<ItemGroup>
<msdeployparametervalue include= "$ (deployparameterprefix) defaultconnection-web.config Connection String" >
<UpdateDestWebConfig>False</UpdateDestWebConfig>
</MSDeployParameterValue>
</ItemGroup>
</Project>
Reference Technical Literature:WEB Application Project Deployment FAQs for Visual Studio and ASP.
- Configure TFS Automatic Publishing
- TFS Installation "Build Configuration"
- No setup required
- The machine where TFS is installed web deploy
- Copy the C:\Program Files (x86) \msbuild\microsoft\visualstudio folder of the computer where Visual Studio 2013 resides, to the same directory as the machine where TFS resides. Old directories can be backed up in advance. If you do not do this, a missing file error will occur.
- Configuring the Auto-build configuration file
Open the ASP. NET project for Visual Studio 2013 (Team project) and click "Generate". The following are important parts.
In the previous picture, MSBuild parameter:/p:deployonbuild=true; PUBLISHPROFILE=WEBAPP01; Allowuntrustedcertificate=true; Password=pwd
This parameter is a critical part of automatic publishing. PUBLISHPROFILE=WEBAPP01 is the name of the Pubxml file, see the first picture in this article, PASSWORD=PWD is the password of the IIS publishing user, the user name is in the Pubxml file.
- At this point, all configurations are complete.
- Test
When you modify the project file and check it in, the publication is automatically compiled.
Extended knowledge: If you want to perform unit tests before compiling a publication, you cannot use the default template in procedures and use a custom build process template
TFS 2013 completes automatic publishing of ASP. NET site with Web deploy