Article From:https://www.cnblogs.com/hnsongbiao/p/9063784.html
cause: our team now uses Visual Studio 2013 to develop asp.net projects and use tfs2013 to do it.Source code management, every morning manually release project files, copy to the test server’s site folder to cover old files, using this way to publish the system, even a number of times a day. Low efficiency and hard work.
asp.netProject release.
 
automatic release system configuration process:
  • Environmental inspection
    1. Client: Visual Studio 2013 development environment, able to connect to the source server (TFs TFs 2013), and get the source code of the check-in project.
    2. Source code server (TFs 2013)
    3. asp.net The server (IIS) is able to access normally, and can use project files to cover the old files under the site folder and visit them normally.
    • Configuring web deploy Publishing
    1. IISInstall the configuration “management service”
      Refer to the second part of this article: teletext detailed remote deployment of ASP.NET MVC 5 project.  
    2. Download and install the web deploy, and recommend the use of “fully installed”. Pay attention to the order of installation: “web deploy” after “management service”. If it is back, “web deploy” needs the last run installer to use the modification function, and finally do it.”Complete installation”.
    3. Test web deploy, using https://IP:8172/MsDeploy.axd This address tests WebDeploy, if the user name password dialog box is popped up, it means that “web deploy” has been installed successfully. You don’t have to wait to see the result.
    4. Using the web deploy release in the visual studio 2013 asp.net project, the asp.net project to IIS asp.net site was successfully released. Such
       Refer to the third part of this article: teletext detailed remote deployment of ASP.NET MVC 5 project.
      This step is crucial to continue the cornerstone of the next step. Attention: pay close attention to the pubxml in the following pictures, and release the configuration files. This is the key to the system.
    5. Add the configuration and test of files that need to be added and excluded when publishing.
      For example, exclude web.config files and fonts folders:
      <ExcludeFilesFromDeployment> 
      web.config 
      </ExcludeFilesFromDeployment> 
      <ExcludeFoldersFromDeployment> 
      fonts 
      </ExcludeFoldersFromDeployment> 
      The complete pubxml file is as follows:
      <?xml version=”1.0″ encoding=”utf-8″?> 
      <!– 
      The publishing / packing process of your Web project will use this file. You can edit this MSBuild file
      From the behavior that defines the process. To learn more about this information, please visit http://go.microsoft.com/fwlink/ LinkID=208121. It
      –> 
      <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> 
      <!– Expelled 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:Be used forCommon problems of Web application project deployment for Visual Studio and ASP.NET

    • Configure TFs automatic release
    1. tfsInstall “generate configuration”
    2. No need to set up
    3. tfsThe machine is installed with web deploy
    4. Copy visual”C:\Program Files of the studio 2013 computer(x86) \MSBuild\Microsoft\VisualStudio “folder” to “TFs” in the machine phase.The same catalogue. You can back up the old directory in advance. If this step is not performed, there will be an error in missing files.
    • Configure the auto generated configuration file
      Open the asp.net project (team project) of visual studio 2013 and click generate. The following is an important part of the screenshot.

      The MSBuild parameter in the previous picture is /p:DeployOnBuild=True; PublishProfile=webapp01; AllowUntrustedCertificate=true; Pas.Sword=pwd
      This parameter is the key part of automatic release. PublishProfile=webapp01 is the name of the pubxml file. See the first picture in this article. Password=pwd is the password for IIS to issue the user, and the user name is in.In the pubxml file.

    • At this point, all configuration is completed.
    • test
      Modify the project files and check in, the system will automatically compile and publish.
    if you want to execute unit tests before the compilation and release, you can’t use the” default template “in the” process “, and use the custom build process template

    Leave a Reply

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