Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TeamCity + MSBuild: Tagging a deployment with a VCS build number

I am using TeamCity 4.5.1 to build and deploy an ASP.Net application to development.

This is working perfectly so far, however, my manager has asked that I tag the folder with the specific SVN Revision from which the source was compiled.

I am using an MSBuild script to do the build and deployment, however, I am unable to successfully retrieve the build number.

Here is the MSBuild command I'm using (sanitized):

<Exec Command="&gt;\\server08\D$\Websites\MYPROJECT\version.txt echo %env.BUILD_VCS_NUMBER%,%env.BUILD_VCS_NUMBER.1%,%system.build.vcs.number%,%system.build.vcs.number.1%,%system.build.number.format%,%system.build.number.format.1%,%system.build.vcs.number.MYPROJECT_Web_Root%,%env.TEAMCITY_VCS_NUMBER_MYPROJECT_Web_Root%" />

Version.txt turns up like this:

,,,,,,,,

Aka, empty. What am I doing wrong? Any better way to do this?

like image 560
John Gietzen Avatar asked Jun 26 '09 19:06

John Gietzen


1 Answers

%env.XYZ% is TeamCity's method of referring to the environment variables, if you want to use them in ITS settings anywhere.

In a batch file or via msbuild, you only want the XYZ part.

echo %BUILD_VCS_NUMBER% > \\path\to\version.txt
like image 91
Dan Fitch Avatar answered Oct 06 '22 00:10

Dan Fitch