TFS build is a technique for Web application continuous Integration Publishing

Source: Internet
Author: User

Because of the interface-oriented programming relationships, many implementations are often dynamic injection runs, and it is unreasonable to directly reference the DLL compilation in a project. Usually we add some XCOPY commands to the Post Build event to copy the DLLs required by the runtime to the output directory. There are some problems with publishing, such as the post Build Event that is not run when you publish a Web App using Visual Studio's publish feature. Similarly, there is a similar problem with TFS build on.

TFS build creates two subdirectories based on the name of the corresponding definition: Source, Binaries,binaries creates the Publish directory "_publishedwebsites" for the Web app, if you want the post Build Event when the DLL is copied to the corresponding directory, the simplest way is to add the xcopy command (such a command may have more than one), such as:

" $ (solutiondir) Buildevents\post-build " " $ (TargetDir) _publishedwebsites\$ (TargetName) \bin\ "

However, the developer will be ambiguous, workload and polluting the post Build Event. What we want to do is to execute a publish command when MSBuild has a parameter value that meets the requirements (this command is the same as what the post Build event does, that is, $ (TargetDir) is different), At this point, you need to modify the project file to add some custom scripts to implement the feature. First add the MSBuild Arguments in the advanced options for build definition, for example:

/p:rms=1

This abbreviation was used because my goal was to integrate with the release Management service. Open the project file (csproj) below, turn on Afterbuild, and add an exec Task

<target name="afterbuild">      <exec command="$ (postbuildevent)   "condition= " "/> </Target>

The above command does not actually achieve the final result, and here itself is a detour. The main problem is the understanding of postbuildevent, in fact, it is also a string variable, in the execution of its internal use of $ (TargetDir) has long been replaced, can not recalculate the results. For example:

<target name="afterbuild" condition="">    < Propertygroup>      <targetdir>$ (TargetDir) _publishedwebsites\$ (TargetName) \bin\</targetdir>    </PropertyGroup>    <message text="$ (TargetDir)" />    < Exec command="$ (postbuildevent)"

The value of TARGETDIR does change, but the value of postbuildevent has been calculated in advance and we can no longer allow it to be computed dynamically. Fortunately, MSBuild 4.0 or later allows us to use a subset. NET code to modify these variables, we just need to call System.String's Replace method, see below:

<target name="afterbuild">      <exec command="$ ( Postbuildevent.replace (&quot;$ (TargetDir) &quot;, &quot;$ (TargetDir) _publishedwebsites\$ (TargetName) \bin\&quot;))" condition="" /></target>

The above method allows the Web app to be fully published and integrated with the release Management service for continuous integration.

TFS build is a technique for Web application continuous Integration Publishing

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.