如何在Nant脚本中执行Teamcity中的环境变量(环境)

如何在Nant脚本中执行Teamcity中的环境变量(环境)

问题描述:

我正在使用TeamCity构建使用Nant脚本的.Net解决方案,并且如果硬编码解决方案路径,一切正常。我想使用TeamCity(env。)中的环境变量作为解决方案路径 - > env.solution.path ----- C:\ a \ testteamcity \ Demo \ deptest.sln内部Nant脚本test.build文件:如何在Nant脚本中执行Teamcity中的环境变量(环境)

<?xml version="1.0"?> 
<project name ="first Nant file" default="compile-solution" > 
<property name="bin.folder.svn" value="C:\a\testteamcity\Demo\bin123"/> 
<property name="bin.folder.sln" value="C:\cicheckout\webapp\bin"/> 

<target name="compile-solution"> 
    <exec program="C:\Program Files (x86)\MSBuild\12.0\Bin\Msbuild.exe" verbose="true" > 
     <arg line="${environment::get-variable('env.solution.path')}" /> 
     <arg value="/p:Configuration=Release" /> 
    </exec> 

<copy todir="${bin.folder.sln}" overwrite="true" failonerror="true"> 
     <fileset basedir="${bin.folder.svn}">   
     </fileset> 
</copy> 
</target> 
</project> 

错误:意外的标记'标点符号'。 表达式:$ {环境::获取变量( 'env.solution.path')} 任何帮助,将great.Thanks

+0

看起来像它可能是因为你使用了引号一样简单,除非这只是一个复制粘贴错误 - 你的' get-variable'参数应该用简单的单引号括起来:'$ {environment :: get-variable('env.solution.path')}' –

+0

这就是复制粘贴错误:[15:59:54] [ NAnt输出]表达式:$ {environment :: get-variable('env.solution.path')} [15:59:54] [NAnt输出] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^ [15:59:54] [NAnt输出]环境变量“env.solution.path”不存在。 –

+0

请注意,您现在有不同的错误。 –

创建system.solution.path - > C:\ A \ testteamcity \演示\在TeamCity的和南特脚本下的系统属性(系统)。deptest.sln - >

<?xml version="1.0"?> 
<project name ="Build-Solution" default="build-solution" > 
<property name="solution.path" value="${system.solution.path}" dynamic="true" unless="${property::exists('solution.path')}"/> 
    <!-- Build solution --> 
<target name="build-solution"> 
<exec program="C:\Program Files (x86)\MSBuild\12.0\Bin\Msbuild.exe" verbose="true" > 
    <arg line="${solution.path}" /> 
    <arg value="/p:Configuration=Release" /> 
</exec> 
</target> 
</project>