[p4] Adding Changelist # of project to .Net Assembly?

Jeff Grills jgrills at drivensnow.org
Thu Oct 19 22:19:12 PDT 2006


I worked on a project which embedding our build information in a module that
was compiled, but that had the negative side effect of itself causing a
build to be necessary.  At that time we were using the head changelist
number for versioning, but maybe if we had used "p4 changes -m 1 //path" to
get the head changelist number as you do, we could have made sure to update
the file only when it was out of date, which would have prevented an
otherwise unnecessary build.

Instead, we used a product called Resource Tuner Console
(http://www.heaventools.com/command-line_resource_editor.htm), and if the
executable been changed  by the build process, we'd invoke this tool on our
executable to brand it with the build information.  It was really useful,
and I'd recommend the tool to others.  I have no affiliation with the
company other than having had been a satisfied customer.  This may be a good
fallback if you can't find a way to update the version in another manner.

j

-----Original Message-----
From: perforce-user-bounces at perforce.com
[mailto:perforce-user-bounces at perforce.com] On Behalf Of Nau, Michael
Sent: Thursday, October 19, 2006 11:35 PM
To: Pavloff, Alex (IE) @ SONOMAEO
Cc: perforce-user at perforce.com
Subject: Re: [p4] Adding Changelist # of project to .Net Assembly?


I started down that same path a few years ago, and discovered no part of a
AssemblyVersion can be larger than 65534. So we ended up stuffing the
changelist number into the AssemblyDescription attribute.

With regards to how we pull the info, we wrap our build with an nant script
that takes care of calling perforce to figure out the latest changelist then
dynamically updating our AssemblyInfo.cs files at build time.

-Mike

-----Original Message-----
From: perforce-user-bounces at perforce.com
[mailto:perforce-user-bounces at perforce.com] On Behalf Of Pavloff, Alex
(IE) @ SONOMAEO
Sent: Thursday, October 19, 2006 6:04 PM
To: perforce-user at perforce.com
Subject: [p4] Adding Changelist # of project to .Net Assembly?

Hi perforce-user,
 
For our C/C++ project We've added a "p4 changes -m1 $...@$(P4CLIENT)" step
to our makefiles -- and taken the output from that and generated a .c file
from this.  This file contains the highest changelist # at the time of build
of the source in the directory.

As long as this was built from checked-in source, it can be used by testers
and what not as a "what I'm testing" #.  If you need to rebuild that
particular rev, sync to the changelist #, rebuild, wa-lah.

Now, I'm thinking about trying to do the same thing with a Visual Studio
2005/C# project -- and I believe that the "correct" way to do this would be
to generate generate the AssemblyVersion attribute from the Perforce
changelist #, such that it'd be 

[assembly: AssemblyVersion("1.0.0.98776")]

Where 98776 is the Changelist #.  Normally this attribute is hardcoded in
the AssemblyInfo.cs file.

Does anyone have any ideas about how to generate this in the Pre-Build steps
for C#/.Net applications?  

Thanks!

	-Alex



More information about the perforce-user mailing list