|
| 1 | +<?xml version="1.0"?> |
| 2 | + |
| 3 | +<project> |
| 4 | + <property name="CompileConfiguration" value="Release" overwrite="false" /> |
| 5 | + <property name="MSBuildPath" value="C:\Program Files (x86)\MSBuild\12.0\bin\msbuild.exe" overwrite="false" /> |
| 6 | + <property name="MSBuildVerbosity" value="minimal" overwrite="false" /> |
| 7 | + <property name="ToolsPath" value="" overwrite="false" /> |
| 8 | + |
| 9 | + <!-- |
| 10 | + # Builds the solution only. |
| 11 | + --> |
| 12 | + <target name="build" depends="clean" description="Builds the solution."> |
| 13 | + <fail if="${string::get-length(Solution) == 0}" message="No Solution was specified." /> |
| 14 | + |
| 15 | + <!-- Build the Visual Studio Solution --> |
| 16 | + <exec program="${MSBuildPath}"> |
| 17 | + <arg line="${Solution}" /> |
| 18 | + <arg line="/detailedsummary" /> |
| 19 | + <arg line="/target:Build" /> |
| 20 | + <arg line="/property:Configuration=${CompileConfiguration};VisualStudioVersion=12.0" /> |
| 21 | + <arg line="/verbosity:${MSBuildVerbosity}" /> |
| 22 | + </exec> |
| 23 | + |
| 24 | + <!-- Skips building again when a nuget project is defined --> |
| 25 | + <property name="NugetProjectBuild" value="false" /> |
| 26 | + </target> |
| 27 | + |
| 28 | + <!-- |
| 29 | + # Builds and publishes the solution. |
| 30 | + --> |
| 31 | + <property name="WebPublishProfile" value="" /> |
| 32 | + <property name="WebPublishProfileFile" value="" /> |
| 33 | + |
| 34 | + <target name="build_publish" depends="clean" description="Builds the solution."> |
| 35 | + <fail if="${string::get-length(WebPublishProfile) == 0}" message="No WebPublishProfile was specified." /> |
| 36 | + |
| 37 | + <!-- Build the Visual Studio Solution --> |
| 38 | + <exec program="${MSBuildPath}"> |
| 39 | + <arg line="${Solution}" /> |
| 40 | + <arg line="/detailedsummary" /> |
| 41 | + <arg line="/target:Build" /> |
| 42 | + <arg line="/property:Configuration=${CompileConfiguration};VisualStudioVersion=12.0" /> |
| 43 | + <arg line="/property:DeployOnBuild=true;PublishProfile=${WebPublishProfile}" if="${file::exists(WebPublishProfileFile)}" /> |
| 44 | + <arg line="/verbosity:${MSBuildVerbosity}" /> |
| 45 | + </exec> |
| 46 | + |
| 47 | + <!-- Skips building again when a nuget project is defined --> |
| 48 | + <property name="NugetProjectBuild" value="false" /> |
| 49 | + </target> |
| 50 | + |
| 51 | + <!-- |
| 52 | + # Run unit tests. |
| 53 | + --> |
| 54 | + <property name="NunitExecutable" value="${path::combine(ToolsPath, 'nunit\bin\nunit-console-x86.exe')}" /> |
| 55 | + |
| 56 | + <target name="nunit_tests" depends="clean" description="Run all unit tests in the solution"> |
| 57 | + <foreach item="File" property="nunit.project"> |
| 58 | + <in> |
| 59 | + <items refid="test.projects" /> |
| 60 | + </in> |
| 61 | + <do> |
| 62 | + <exec program="${NunitExecutable}"> |
| 63 | + <arg value="${nunit.project}" /> |
| 64 | + <arg value="/xml:artifacts\nunit-results.xml" /> |
| 65 | + <arg value="/framework:net-4.0" /> |
| 66 | + <arg value="/config:${CompileConfiguration}" /> |
| 67 | + </exec> |
| 68 | + </do> |
| 69 | + </foreach> |
| 70 | + </target> |
| 71 | + |
| 72 | + <!-- |
| 73 | + # Cleanup the solution back to an initial state. |
| 74 | + --> |
| 75 | + <property name="ArtifactsCleaned" value="false" /> |
| 76 | + |
| 77 | + <target name="clean" description="Clean up solution after a build and revert it to its pre-build state."> |
| 78 | + <if test="${not ArtifactsCleaned}"> |
| 79 | + <delete dir="artifacts" if="${directory::exists('artifacts')}" /> |
| 80 | + <delete dir="packages" if="${directory::exists('packages')}" /> |
| 81 | + <property name="ArtifactsCleaned" value="true" /> |
| 82 | + </if> |
| 83 | + <mkdir dir="artifacts" if="${not directory::exists('artifacts')}" /> |
| 84 | + <exec program="${MSBuildPath}"> |
| 85 | + <arg line="${Solution}" /> |
| 86 | + <arg line="/fileLogger" /> |
| 87 | + <arg line="/flp:logfile=artifacts\build.log" /> |
| 88 | + <arg line="/property:Configuration=${CompileConfiguration};VisualStudioVersion=12.0" /> |
| 89 | + <arg line="/target:Clean" /> |
| 90 | + <arg line="/verbosity:${MSBuildVerbosity}" /> |
| 91 | + </exec> |
| 92 | + </target> |
| 93 | + |
| 94 | + <!-- |
| 95 | + # Restores any dependency nuget packages used by the solution. |
| 96 | + --> |
| 97 | + <property name="NugetExecutable" value="${path::combine(ToolsPath, 'nuget.exe')}" /> |
| 98 | + <property name="NugetVerbosity" value="normal" /> |
| 99 | + |
| 100 | + <target name="nuget_restore" depends="clean" description="Fetch nuget packages for the solution."> |
| 101 | + <exec program="${NugetExecutable}"> |
| 102 | + <arg line="restore ${Solution}" /> |
| 103 | + <arg line="-Verbosity ${NugetVerbosity}" /> |
| 104 | + </exec> |
| 105 | + </target> |
| 106 | + |
| 107 | + <!-- |
| 108 | + # Publishes the NuGet projects. |
| 109 | + --> |
| 110 | + <property name="NugetPublish" value="true" /> |
| 111 | + <property name="NugetPublishKey" value="HomenetPublisher:homenet" /> |
| 112 | + <property name="NugetPublishUrl" value="http://h3p-nuget1.na.autotrader.int/nuget/HomeNet" /> |
| 113 | + <property name="NugetProjectBuild" value="true" /> |
| 114 | + |
| 115 | + <target name="nuget_publish" depends="clean"> |
| 116 | + <!-- Define and create nuget output path --> |
| 117 | + <property name="NugetOutputPath" value="artifacts\nuget" /> |
| 118 | + <mkdir dir="${NugetOutputPath}" if="${not directory::exists(NugetOutputPath)}" /> |
| 119 | + |
| 120 | + <!-- Clean up old nuget packages --> |
| 121 | + <delete> |
| 122 | + <fileset> |
| 123 | + <include name="${NugetOutputPath}\*.nupkg" /> |
| 124 | + </fileset> |
| 125 | + </delete> |
| 126 | + |
| 127 | + <!-- Build nuget package --> |
| 128 | + <foreach item="File" property="nuget.project"> |
| 129 | + <in> |
| 130 | + <items refid="nuget.projects" /> |
| 131 | + </in> |
| 132 | + <do> |
| 133 | + <loadfile file="${path::combine(path::get-directory-name(nuget.project), 'VERSION')}" property="package_version" failonerror="false" /> |
| 134 | + <exec program="${NugetExecutable}"> |
| 135 | + <arg line="pack "${nuget.project}"" /> |
| 136 | + <arg line="-Build" if="${NugetProjectBuild}" /> |
| 137 | + <arg line="-NonInteractive" /> |
| 138 | + <arg line="-OutputDirectory ${NugetOutputPath}" /> |
| 139 | + <arg line="-Properties Configuration=${CompileConfiguration}" /> |
| 140 | + <arg line="-Symbols" /> |
| 141 | + <arg line="-Verbosity ${NugetVerbosity}" /> |
| 142 | + <arg line="-Version ${package_version}" if="${package_version!=''}" /> |
| 143 | + </exec> |
| 144 | + </do> |
| 145 | + </foreach> |
| 146 | + |
| 147 | + <!-- Publish nuget package --> |
| 148 | + <foreach item="File" property="nuget.package" if="${NugetPublish}"> |
| 149 | + <in> |
| 150 | + <items> |
| 151 | + <include name="${NugetOutputPath}\*.nupkg" /> |
| 152 | + </items> |
| 153 | + </in> |
| 154 | + <do> |
| 155 | + <exec program="${NugetExecutable}" if="${string::contains(nuget.package, '.symbols.nupkg')}" failonerror="false"> |
| 156 | + <arg line="push "${nuget.package}"" /> |
| 157 | + <arg line="-ApiKey ${NugetPublishKey}" /> |
| 158 | + <arg line="-Source ${NugetPublishUrl}" /> |
| 159 | + <arg line="-Verbosity ${NugetVerbosity}" /> |
| 160 | + </exec> |
| 161 | + <exec program="${NugetExecutable}" unless="${string::contains(nuget.package, '.symbols.nupkg')}"> |
| 162 | + <arg line="push "${nuget.package}"" /> |
| 163 | + <arg line="-ApiKey ${NugetPublishKey}" /> |
| 164 | + <arg line="-Source ${NugetPublishUrl}" /> |
| 165 | + <arg line="-Verbosity ${NugetVerbosity}" /> |
| 166 | + </exec> |
| 167 | + </do> |
| 168 | + </foreach> |
| 169 | + </target> |
| 170 | + |
| 171 | + <!-- |
| 172 | + # Updates the revision based on the SVN revision. |
| 173 | + --> |
| 174 | + <property name="SvnExecutable" value="svn.exe" /> |
| 175 | + |
| 176 | + <target name="update_revision" depends="clean" description="Copy the current SVN revision number"> |
| 177 | + <exec program="${SvnExecutable}" commandline="info --xml" output="_revision.xml" /> |
| 178 | + <xmlpeek file="_revision.xml" xpath="/info/entry/commit/@revision" property="RevisionNumber" /> |
| 179 | + <echo file="revision.txt">${RevisionNumber}</echo> |
| 180 | + <if test="${property::exists('CCNetLabel')}"> |
| 181 | + <echo file="version.txt">${CCNetLabel}</echo> |
| 182 | + </if> |
| 183 | + </target> |
| 184 | + |
| 185 | +</project> |
0 commit comments