TFS 2013 completes automatic publishing of ASP. NET site with Web deploy

Source: Internet
Author: User

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:
    • Environmental inspection
    1. Client: Visual Studio 2013 development environment, ability to connect to source server (TFS 2013) Normally, get checked in ASP. NET project Source code
    2. Source server (TFS 2013)
    3. 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
  1. IIS installation Configuration "Management Services"
    Refer to the second part of this article: Graphic details remote deployment ASP. NET MVC 5 Project
  2. 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".
  3. 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.
  4. 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.
  5. 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
    1. TFS Installation "Build Configuration"
    2. No setup required
    3. The machine where TFS is installed web deploy
    4. 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

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.