Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I coordinate assembly version information in my tree of many C# projects?

What approaches have you taken to coordinating changes to version and Copyright for groups of assemblies?

I have a tree of many csprojs each with its own AssemblyInfo file. As part of my build process I want to set copyright year and version. It looks like the following options be be available but file modification is the only one I've seen thus far:

  • Modify all files via script
  • Include resource with date (a macro, a singleton class with public static variables)
  • Override AssemblyVersion on command line ( -DAssemblyVersion="1.0.0.1" ?)
  • Reference Environment variable ([assembly: AssemblyFileVersion("${ENV.VERSION")])

I'm used to keeping the source tree clean of generated files in Java/C++ via command line params, defines and centralizing all version specification in a single file.

What approach to do you use to keep the versions in sync and manageable?

Thanks

Peter

like image 686
Peter Kahn Avatar asked Jul 11 '11 22:07

Peter Kahn


People also ask

How do I find the assembly version?

I can get the Assembly Version with the following line of code: Version version = Assembly. GetEntryAssembly(). GetName().

Where is version information stored of an assembly?

The version number is stored in the assembly manifest along with other identity information, including the assembly name and public key, as well as information on relationships and identities of other assemblies connected with the application.

What is assembly version and file version?

It's the version number given to file as in file system. It's displayed by Windows Explorer, and never used by . NET framework or runtime for referencing.

What do you understand by assembly version?

It's the version number used by framework during build and at runtime to locate, link, and load the assemblies. When you add reference to any assembly in your project, it's this version number that gets embedded.


1 Answers

In the top folder, I place a CommonAssemblyInfo.cs that contains the ... common stuff, such as copyright and FileVersion. This file is just contains some default attributes and is regenerated by a script(a simple .bat file) on the build server, Hudson in my case. Remove these common attributes in each of the projects AssemblyInfo.cs.

In each project in the solution, I add this file. but use "Add as link" - available in the drop down of the "Add" button when you add an existing file. i.e. all projects just contains a reference to the same file, so there's only one file to update.

like image 136
nos Avatar answered Oct 11 '22 18:10

nos