Thanks!!
R.
We use some script to do a search/replace on the version numbers in
the AssemblyFileVersion tag in all AssemblyInfo.cs files in the source
tree. This leaves whatever other metadata is in the AssemblyInfo.cs
files intact:
<foreach item="File" property="filename">
<in>
<items basedir="${CCNetWorkingDirectory}">
<include name="**\AssemblyInfo.cs"></include>
</items>
</in>
<do>
<echo message="Updating ${filename}" />
<script language="C#">
<code><![CDATA[
public static void ScriptMain(Project project)
{
//FileStream file = File.Open(project.Properties["filename"],
FileMode.Open, FileAccess.ReadWrite);
StreamReader reader = new StreamReader(project.Properties["filename"]);
string contents = reader.ReadToEnd();
reader.Close();
string replacement = string.Format(
"AssemblyFileVersion(\"{0}.{1}.{2}.{3}\")]",
project.Properties["build.version.major"],
project.Properties["build.version.minor"],
project.Properties["build.version.revision"],
project.Properties["build.version.build"]
);
string newText = Regex.Replace(contents,
@"AssemblyFileVersion\("".*""\)\]", replacement);
StreamWriter writer = new
StreamWriter(project.Properties["filename"], false);
writer.Write(newText);
writer.Close();
}
]]>
</code>
</script>
</do>
</foreach>
A couple of things to note:
-We only update the AssemblyFileVersion because we strong sign the
assemblies and if we rev the AssemblyVersion each time, it'll break
references every build.
-We manage the version numbers entirely outside of CCNet using a text
file with the build number. The text file is force synced checked out,
number incremented, and not checked back in until after a successful
build is published. This way, we ensure that versions received by Q/A
are always consecutive (which makes defect tracking much easier).
-The AssemblyInfo.cs files are not checked back in and the "stock"
AssemblyFileVersion is 1.0.0.0, so it's easy to tell if someone's
using an "official" file, or something compiled on a developer box.
--
-Chris
> Unfortunately, this does more than just "touch" an AssemblyInfo file
> -- it looks like it can only create new ... so what happens to
> AssemblyInfo attributes being set by developers?
At the risk of souding like a broken record, I'll plug an Apress book
called "Expert .NET Delivery Using NAnt and CruiseControl.NET". This
exact situation is addressed in there. It uses two separate files. One
file contains the project specific attributes, such as assembly name,
etc. The other contains the stuff that might be changed by the build,
or that the company wants to ensure are in each build, such as the build
number and copyright information.
Brad
-----Original Message-----
From: ccnet...@googlegroups.com [mailto:ccnet...@googlegroups.com]On
Behalf Of Brad Stiles
Sent: Monday, July 30, 2007 2:35 PM
To: ccnet...@googlegroups.com
Subject: [ccnet-user] Re: Incrementing build numbers
That book is on my list with Amazon actually, looking forward to reading it when I get through some Martin and Schwaber stuff on Agile and Scrum.
The problem with having a file for those attributes is that they must be universal to all projects that are part of this process, and/or they need to be maintained by the deployment/change management people, rather than developers. This can lead to a problem where, say, a developer sets CLS compliancy to true to resolve an issue in development, and if/when the issue surfaces in testing, or worse, production, no one knows why without a lot of digging.
I'm actually writing a NAnt task now ... I'll make it available to anyone else who could use it.
On 7/30/07, Brad Stiles < bradley...@gmail.com> wrote:
1) Get the AssemblyInfo from Source Safe
2) Increment the BuildNumber based on the CCNetLabel
3) Check the AssemblyInfo back in to SourceSafe
Here is the Increment target:
<!-- Increment the AssemblyVersion -->
<Target Name="IncrementAssemblyVersion">
<Message Text="===== Starting IncrementAssemblyVersion... =====" />
<!-- Modify AssemblyInfo.vb $(CCNetLabel) is sent from CCNet -->
<FileUpdate Files="$(BuildPath)\AssemblyInfo.vb"
Regex="AssemblyVersion\d*.*"
ReplacementText="AssemblyVersion("$(CCNetLabel)")>" />
<Message Text="===== ... IncrementAssemblyVersion finished. =====" /
>
</Target>
On Jul 30, 4:44 pm, "Andrew Badera" <andrew.bad...@gmail.com> wrote:
> http://andrew.badera.us/AsmVersionTask.Task/AsmVersionTask.Tasks.zip
>
> I'm only looking to increment the build number, so that's what the task is
> set up for, but it should also give anyone who wants it a basis for altering
> their choice of AssemblyVersion values. If you don't get the zip, contact
> me, we can figure something else out.
>
> <BuildIncrementTask
> AsmName="[AssemblyName]"
> LocalPath="[LocalRoot]"
> BranchOrTrunk="[Any branching etc. folder(s) under the project's main
> folder]"
> />
>
> BranchOrTrunk is used for branch or trunk folders under your main project
> folder:
> $/Company/Product/Project/Trunk/Properties/AssemblyInfo.cs
> $/Company/Product/Project/Branch 06_06_2007/Properties/AssemblyInfo.cs
>
> You can omit the BranchOrTrunk value if instead your path looks like:
> $/Company/Product/Project/Properties/AssemblyInfo.cs
>
> Critiques welcome. Questions answered. No, it's not the neatest piece of
> code either, I'm probably going to do more work on it, and factor out some
> likely reusable stuff.
>
> --Andrew Badera
> andrew.bad...@gmail.comhttp://andrew.badera.us/
>
> On 7/30/07, Andrew Badera <andrew.bad...@gmail.com> wrote:
>
>
>
> > That book is on my list with Amazon actually, looking forward to reading
> > it when I get through some Martin and Schwaber stuff on Agile and Scrum.
>
> > The problem with having a file for those attributes is that they must be
> > universal to all projects that are part of this process, and/or they need to
> > be maintained by the deployment/change management people, rather than
> > developers. This can lead to a problem where, say, a developer sets CLS
> > compliancy or COM visibility to resolve an issue in development, and if/when
> > the issue surfaces down the line in testing, QA, or worse, production, no
> > one knows why without a lot of digging.
>
> > I'm actually writing a NAnt task now ... I'll make it available to anyone
> > else who could use it. It will scoop up and retain the existing attributes
> > of the assembly, and only do work on the version.
>
> > On 7/30/07, Brad Stiles <bradley.sti...@gmail.com> wrote:
In the registry, the Visible setting is 0.
Any ideas why this is starting visible?
--Brian
For our projects we do it with a nant script that is called before the
compiler is called:
cruisecontrol.net configuration:
<nant>
<executable>C:\Program Files\Nant\bin\nant.exe</executable>
<buildFile>C:\Projects\Configuration\SetVersion.build</buildFile>
<buildArgs>-D:VersionFile=AssemblyInfo.cs</buildArgs>
</nant>
nant script:
<?xml version="1.0" ?>
<project name="Set release version number" default="version" basedir=".">
<description>Sets the Version with the CruiseControl.NET Build Number
as the Revision Number.</description>
<target name="version" description="sets the release version number">
<delete file="${CCNetWorkingDirectory}\${VersionFile}.new"
if="${file::exists(CCNetWorkingDirectory + '\' + VersionFile +
'.new')}" />
<loadfile file="${CCNetWorkingDirectory}\${VersionFile}"
property="VersionInfo" />
<regex pattern="^(?'begin'.*AssemblyVersion\(.\d+\.\d+\.\d+\.)\d+(?'end'.*)$"
input="${VersionInfo}" options="Singleline"/>
<echo file="${CCNetWorkingDirectory}\${VersionFile}.new">${begin}${CCNetLabel}${end}</echo>
<copy file="${CCNetWorkingDirectory}\${VersionFile}.new"
tofile="${CCNetWorkingDirectory}\${VersionFile}" />
</target>
</project>
You haev to ensure that the version is in the Format "1.0.0.0" (and
not with stars like the default value "1.0.*").
Like this all the additional data in the assemlyInfo.cs file stays and
just the last number is set to the build number.
Greetings
Roland
On 7/30/07, rra866 <rra...@gmail.com> wrote:
>