I'm trying to use a teamcity agent property in my nant scripts. This works perfectly when I run the build using teamcity. However, since there is no way to evaluate the property outside teamcity, the scripts fail when I run nant via commandline. Here is the sample code -
<?xml version="1.0"?>
<project name="script" default = "publish">
<target name="publish">
<echo message="${agent.home.dir}"/>
</target>
</project>
I'm sure I'm missing something very basic in this. Please Help!
I had a similar issue when using NAnt with TeamCity as it will work fine running it from TeamCity but if you do the build via command line it will fail because NAnt does not know what those TeamCity variables are.
My Solution was simple. Since the only time my build needed to interact with TeamCity is during a TeamCity invoked build I gave the user the option to turn off that feature if needed to run it from a command line.
Example:
<property name="TeamCity.BuildFeatures" value="false" />
<if test="${bool::parse(TeamCity.BuildFeatures)}" >
<echo message="Your TeamCity variables like ##teamcity[] are ignored" />
</if>
Hope this is useful..
EDIT Based on Comments:
<property name="agent.home.dir" value="..\TeamCity\BuildAgent" />
<exec program="msbuild.exe" basedir="${msbuilddir}" commandline="\testProject.csproj">
<arg value="/property:Configuration=Release;Platform=x86"/>
<arg value="/verbosity:diagnostic"/> <arg value="Verbosity=diagnostic;Encoding=UTF-8"/>
<if test="${property::exists('agent.home.dir')}" >
<arg value="/l:JetBrains.BuildServer.MSBuildLoggers.MSBuildLogger,${agent.home.dir}\plugins\dotnetPlugin\bin\JetBrains.BuildServer.MSBuildLoggers.dll" if="${teamcity}" />
</if>