Assembly Info Patcher & Linked AssemblyInfo.cs

Hi,

We have a linked assembly info across projects and was wondering if I could use the assembly info patcher on the same. Looks like there is a restrictrion on the name that the patcher looks for. Our linked file is called GlobalAssemblyInfo.cs.

Any suggestions on the same is greatly appreciated.

Thanks,
Balaji

6 comments
Comment actions Permalink

The documentation states that the patcher only works with standard VS projects, so I guess you cannot solve this problem. The AssemblyInfo Patcher is a nice addition, although I think it still needs some improvements to become really usable, like allowing some more versioning customization, ignoring the AssemblyVersion attribute, etc.

JMHO.

0
Comment actions Permalink

My thoughts exactly. So I went ahead and added a new powershell build step to patch the file myself. The script takes in the version number as an argument.

#This powershell script is used by TeamCity build server to patch the
#GlobalAssemblyInfo.cs file with the latest build number.
$assemblyVersion = '[assembly: Assembly$1Version("' + $args[0] + '")]'
$file = "GlobalAssemblyInfo.cs"

$fileObject=get-item $file

$isReadOnly = $False

if($fileObject.Get_IsReadOnly()) {
   $isReadOnly = $True
   $fileObject.Set_IsReadOnly($False) }
   else {
          $isReadOnly = $False
}

$sr = new-object System.IO.StreamReader( $file, [System.Text.Encoding]::GetEncoding("utf-8") )
$content = $sr.ReadToEnd()
$sr.Close()

$content = [Regex]::Replace( $content, '\[assembly\:\sAssembly(File)?Version\(\"[0-9\.]+\"\)\]',  $assemblyVersion);

$sw = new-object System.IO.StreamWriter( $file, $false, [System.Text.Encoding]::GetEncoding("utf-8") )
$sw.Write( $content )
$sw.Close()

if($isReadOnly) {
   $fileObject.Set_IsReadOnly($True)
}


Cheers,
Balaji

0
Comment actions Permalink

We've been following this article for quite some time now. Works well enough for us.
http://blog.benhall.me.uk/2008/06/team-city-update-assemblyinfo-with.html

0
Comment actions Permalink

Hi Matt,

We had a similar setup with CruiseControl.NET and MSBuild. But since moving to Teamcity, we are using the sln file to build the project and not MSBuild. In that case smething like the script above should help.

Cheers,
Balaji

0
Comment actions Permalink

I use a similar approach, instead of creating a new AssemblyInfo file, I modify the existing one with the FileUpdate task of the MSBuildCommunityTasks package.

0
Comment actions Permalink

We would really appreciate if you create a feature request in our tracker and describe there what is currently missing in the Assembly Info patcher. This would help us a lot to make it more flexible.

0

Please sign in to leave a comment.