views:

443

answers:

1

Does anyboy know how to pass the LastChangeNumber parameter into MSBuild?

I'm trying to use this:

<Exec Condition=" '$(LastChangeNumber)' != '' " Command=">\\server\destination\subversion_revision.txt echo subversion $(LastChangeNumber)" />

Which successfully ignores the condition if I leave out the LastChangeNumber parameter from the MSBuild, and succeeds if I pass in a bunk parameter like /p:LastChangeNumber=foo. However, when I try this:

  <msbuild>
    <executable>C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe</executable>
    <projectFile>MySolution.sln</projectFile>
    <buildArgs>/noconsolelogger /p:Configuration=Debug /p:LastChangeNumber=$(LastChangeNumber) /v:diag</buildArgs>
    <logger>C:\Program Files\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MsBuild.dll</logger>
  </msbuild>

I get an error in my CrusieControl.NET server log:

ThoughtWorks.CruiseControl.Core.Config.Preprocessor.EvaluationException: Reference to unknown symbol LastChangeNumber

+2  A: 

Well, I found ONE way to do it:

<Exec Command=">$(DeployDir)label.txt echo subversion $(CCNetLabel)" />

With a custom labeler:

<labeller type="assemblyVersionLabeller">
  <major>2</major>
  <minor>0</minor>
</labeller>
John Gietzen
$(LastChangeNumber) is set or a process that is called by CCNet. The process itself has to replace the environment varibales. It seems that this isn't done by msbuild. So your solution seems to be at least one way to get it working.
PVitt