简体   繁体   中英

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

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. ie all projects just contains a reference to the same file, so there's only one file to update.

Regardless of which route you take to actually update the version number, you can use an individual AssemblyInfo.cs file to specify a shared version.

Create the file at some level above the other projects, in terms of structure, then add it to all projects (from within Visual Studio), but when doing so be sure to select 'Add as link'.

I've used an MSBuild task to handle the updating, too, I just can't think of it - which build engine do you use?

You can theoretically have one single assembly file. Just link the file in all other projects: Add existing file >> link file instead of adding (button dropdown)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM