Hi all,
we use CVS to manage versions of our code. Since the CVS keeps track of
everything we need I want to synchronize the assembly info with CVS.
The problem is that if I update the assembly info the file is no longer
up-to-date with our CVS-repository. Also if I check the file in to the
CVS-repository the assembly info is no longer up-to-date.
I've seen the 1.0.* -trick and I can accept it on the AssemblyVersion
but the AssemblyFileVersion should be in sync with the CVS's
fileversion.
I also tried using
[assembly: AssemblyFileVersion("$Revision: 2.345 $")]
but it is ugly and it gives me a warning upon compilation.
Has anyone done this before me and found a solution? (Anything is
helpful)
*Current solution*
The information I want to use is found in f.x. the text generated in
$Id $ by CVS, typically it expands to something like this when I check
into CVS:
$Id: AssemblyInfoGenerator.cs,v 2.345 2007/01/18 13:04:12 per Exp $
($Id: filename,v version date time user status$)
I made a little program that scans my folders for .cs files and if it
finds one it scans the file for the Id-tag, and if it finds any Id-tag
it updates the AssemblyInfo (if it finds it) of the file by this
pattern:
majorVersion = "1."
AssemblyVersion = majorVersion . year . dayofyear . minuteofday
AssemblyFileVersion = majorVersion . CVSversion
Example:
// $Id: AssemblyInfoGenerator.cs,v 2.345 2007/01/18 13:04:12 per Exp $
// using...
[assembly: AssemblyTitle("AssemblyInfoGenerator")]
[assembly: AssemblyVersion("1.2007.18.252")] // major version . year .
dayofyear . minuteofday
[assembly: AssemblyFileVersion("1.2.345")] // majorversion . CVSversion
// more items that are static
// the rest of the file
But since CVS needs to have checked in to have the $Id $ up-to-date I
cannot generate the assembly info before I check in. And vice versa.
*Another try*
I also tried using some strings that I cut and pasted in, for example
string author = "$Author: per $";
string revision = "$Revision: 2.345 $";
But it seems I cannot execute code in these lines. Something that would
have been great is:
[assembly: AssemblyFileVersion("1."+"$Revision: 2.345
$".Replace("Revision:", "").Replace("$", "").Replace(" ", "") + ".0")]
gives me
Error 1 An attribute argument must be a constant expression, typeof
expression or array creation
expression C:\work\v5\devTools\AssemblyInfoTests\CVS2Assembly \CVS2Assembly.cs 24 32 CVS2Assembly
*Ugly solution (using DoubleThink)*
I could do something like this: before checking in a file I update to
this
version = major version . year . month .dayofmonth
fileversion = major version . current CVS major version . *current
CVS minor version + 1*
This could work just fine but is not as pretty as having assembly info
generated, also it does not give me the time, only the date (pretty
acceptable perhaps).
Any comments on how one *should* do (and how you do do) are welcome.
Thanks,
Per Erik Strandberg
Tired of loosing file when deleting from the console?
Try toTrash: http://www.pererikstrandberg.se/projects/totrash/
----------------------------
"It is white."
-George W. Bush, asked by a child in Britain what the White House was
like.