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 ("$ (TargetDir) ", "$ (TargetDir) _publishedwebsites\$ (TargetName) \bin\"))" 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