Created
August 19, 2010 19:15
-
-
Save house9/538649 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<project name="YourApp" default="do-build" xmlns="http://nant.sf.net/release/0.85-rc4/nant.xsd"> | |
<!-- Version settings --> | |
<property name="project.config" value="release" /> | |
<property name="project.version.major" value="1" /> | |
<property name="project.version.minor" value="0" /> | |
<property name="project.version.build" value="0" /> | |
<property name="tfs.server" value="http://yourTFSserver:8080/" /> | |
<property name="tfs.fullpath" value="$/yourTeamProject/someDirectory/andSoOn/" /> | |
<property name="company" value="${project::get-name()}"/> | |
<property name="project" value="${project::get-name()}"/> | |
<property name="copyright" value="${company}, ${datetime::get-year(datetime::now())}"/> | |
<property name="temp-target-dir" value="C:\temp\yourApplication"/> | |
<!-- the public target --> | |
<target name="do-build" depends="version, compile-release, copy-to-temp-dir"/> | |
<target name="compile-release"> | |
<!-- delete the previous log files --> | |
<delete file="clean_log.txt" failonerror="false"></delete> | |
<delete file="compile_log.txt" failonerror="false"></delete> | |
<!-- clean --> | |
<echo message="Clean bins" /> | |
<exec program="c:\program files\microsoft visual studio 9.0\common7\ide\devenv.exe" workingdir="."> | |
<arg file="YourSolutionFileNameHere.sln" /> | |
<arg value="/out" /> | |
<arg value="clean_log.txt" /> | |
<arg value="/clean" /> | |
<arg value="${project.config}" /> | |
</exec> | |
<!-- build --> | |
<echo message="Build for ${project.config}" /> | |
<exec program="c:\program files\microsoft visual studio 9.0\common7\ide\devenv.exe" workingdir="."> | |
<arg file="YourSolutionFileNameHere.sln" /> | |
<arg value="/out" /> | |
<arg value="compile_log.txt" /> | |
<arg value="/rebuild" /> | |
<arg value="${project.config}" /> | |
</exec> | |
</target> | |
<target name="version"> | |
<property name="project.version.revision" value="0"/> | |
<!-- this block get the changesetid for this 'solution' and sets project.version.revision --> | |
<script language="C#"> | |
<references> | |
<include name="C:\someDirectoryWhereYouHaveThisDll\Microsoft.TeamFoundation.Client.dll" /> | |
<include name="C:\someDirectoryWhereYouHaveThisDll\TeamFoundation\Microsoft.TeamFoundation.VersionControl.Client.dll" /> | |
</references> | |
<imports> | |
<import namespace="Microsoft.TeamFoundation.Client" /> | |
<import namespace="Microsoft.TeamFoundation.VersionControl.Client" /> | |
</imports> | |
<code> | |
<![CDATA[ | |
public static void ScriptMain(Project project) | |
{ | |
// see c# code sample in next section... | |
} | |
]]> | |
</code> | |
</script> | |
<property name="project.version.full" value="${project.version.major}.${project.version.minor}.${project.version.build}.${project.version.revision}"/> | |
<echo message="MARKING THIS BUILD AS VERSION ${project.version.full}" /> | |
<delete file="CommonAssemblyInfo.cs" failonerror="false"/> | |
<asminfo output="CommonAssemblyInfo.cs" language="CSharp"> | |
<imports> | |
<import namespace="System" /> | |
<import namespace="System.Reflection" /> | |
<import namespace="System.Runtime.InteropServices" /> | |
</imports> | |
<attributes> | |
<attribute type="ComVisibleAttribute" value="false" /> | |
<attribute type="AssemblyVersionAttribute" value="${project.version.full}" /> | |
<attribute type="AssemblyFileVersionAttribute" value="${project.version.full}" /> | |
<attribute type="AssemblyCopyrightAttribute" value="${copyright}" /> | |
<attribute type="AssemblyProductAttribute" value="${project}" /> | |
<attribute type="AssemblyCompanyAttribute" value="${company}" /> | |
<attribute type="AssemblyConfigurationAttribute" value="${project.config}" /> | |
<attribute type="AssemblyInformationalVersionAttribute" value="${project.version.full}" /> | |
</attributes> | |
<references> | |
<include name="System.dll" /> | |
</references> | |
</asminfo> | |
</target> | |
<target name="copy-to-temp-dir"> | |
<mkdir dir="${temp-target-dir}" /> | |
<exec program="xcopy" verbose="true"> | |
<arg value=".\YourWebProjectDirectory" /> | |
<arg value="${temp-target-dir}" /> | |
<arg line="/e /r /y /q" /> | |
</exec> | |
<delete> | |
<!-- probably a better way to do this? --> | |
<fileset basedir="${temp-target-dir}"> | |
<include name="*.cs" /> | |
<include name="*/*.cs" /> | |
<include name="*.csproj*" /> | |
<include name="*/*.otherfiletypes" /> | |
</fileset> | |
</delete> | |
<!-- fix up the web.config --> | |
<echo message="update the configuration ${temp-target-dir}\web.config" /> | |
<xmlpoke | |
file="${temp-target-dir}\web.config" | |
xpath="/ns:configuration/ns:system.web/ns:customErrors/@mode" | |
value="On" | |
> | |
<namespaces> | |
<namespace prefix="ns" uri="http://schemas.microsoft.com/.NetConfiguration/v2.0" /> | |
</namespaces> | |
</xmlpoke> | |
</target> | |
</project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment