Update version number in vbproj file in NAnt build

Today, I got an exact same challenge Scot Hanselman faced 8 years ago. 

Copied his script into my build file, error said: Regex does not exist.

Added system.dll reference in NAnt according to this post, no help.

I stopped, why bother using Regex for such a small task.

I turn back to native NAnt tasks. Strategy is,

  1. Find the hardcoded version number in vdproj file, e.g., 1.1.0, notify team member don’t touch it, this will be my constant, or token to be replaced later.
  2. Replace this 1.1.0 on the fly during the build, build msi. Create backup vdproj file before replacing.
  3. When build finished, restore original vdproj.

Simple and clean solution, job accomplished.

Only goofy part is, if I run this build script when Visual Studio opened, VS kept saving memory cached content to disk, causing file conflict.

Not a big deal, this build target only runs on our CI server anyway.

  <property name="orig.version.number.in.vdproj" value="1.1.0" /> <!--ensure this matches vdproj-->
  <property name="path.vdproj.file" value="src\EmailProcessorNTServiceSetup\EmailProcessorNTServiceSetup.vdproj" />
  <property name="path.vdproj.file.orig" value="${path.vdproj.file}.orig" />

  <target name="update.vdproj.version" depends="">
    <loadfile file="${path.vdproj.file}" property="file.contents" />
	<!-- build.number in format of xx.xx.xx.xx, need to shorten to xx.xx.xx to satisfy vdproj -->
    <property name="version.number" value="${string::substring(build.number, 0, string::last-index-of(build.number, '.'))}"/>
	<echo message="shorteded version.number: ${version.number}" />
    <echo file="${path.vdproj.file}" message="${string::replace(file.contents, orig.version.number.in.vdproj, version.number)}" />

  <target name="restore.vdproj.file" depends="">
    <delete file="${path.vdproj.file}" />
	<echo message="${path.vdproj.file} could not be deleted" if="${file::exists(path.vdproj.file)}" />

	<if test="${not file::exists(path.vdproj.file)}">
		<copy file="${path.vdproj.file.orig}"

		<delete file="${path.vdproj.file.orig}" />
<!-- can also replace it back, same result, but this potentially still mess up svn flag.    <echo file="${path.vdproj.file}" message="${string::replace(file.contents, version.number, orig.version.number.in.vdproj)}" />-->

Setup git access on TeamCity behind firewall

Problem: Our CI server needs to grab the source code from external world to run a build.

Use git behind firewall

git config –global -l
check http.proxy=?

git config -global http.proxy=http://proxy-server:port-number
If reset is necessary,
git config –global  unset http.proxy
or  git config –global unset-all http.proxy


Configure TeamCity connect to external git repository

So far there is no place to set http proxy in teamcity yet. (we are on teamcity 7.03)

One easiest solution is:

  1. git clone to local repo folder, e.g. c:/git_repo>git clone https://remote-git myrepo
  2. share this folder on local network
  3. in TeamCity, VCS settings, set remote fetch url to \\repo-host\myrepo
  4. tahdah…it works!

Remaining problem is we still need to manually run git pull on git_repo folder to get latest from remote, maybe a cron job can make this easier.