3

I have a solution that includes about 70 projects, each with its individual version (We are following the Version pattern).

We would like to manage the assemblies versions in a single file, something like a CommonAssembliesVersions.cs file as suggested in other questions/answers.

The only problem is that by doing so we are giving to each assembly the same version. Is possible to specify what version to assign to which assembly? something like

[assembly "AssemblyName1":AssemblyVersion("0.0.1.1")]
[assembly "AssemblyName2":AssemblyVersion("1.2.4.1")]
[assembly "AssemblyName3":AssemblyVersion("4.0.54.3001")]

and so on?

marsze
  • 15,079
  • 5
  • 45
  • 61
  • 3
    Maybe with a unique compile constant per project `#define Assembly1` and then in the common file: `#if Assembly1 [assembly:AssemblyVersion("0.0.1.1")] #endif` but I didn't test this so I'm not sure if this will fly. – rene Oct 24 '18 at 08:48
  • Your question is sadly too broad and reads as a set of requirements. [ask] –  Oct 24 '18 at 08:49
  • @MickyD really? How much more info is needed? – rene Oct 24 '18 at 08:51
  • Isn't the reason to use a `CommonAssembliesVersion.cs` to give the same version to all assemblies? If each assembly has its own version, just put it in each one's own `AssemblyInfo.cs`. – Haukinger Oct 24 '18 at 09:08
  • @Haukinger I assume managing versions in a single file is simply A LOT easier when there are 70+ projects. – marsze Oct 24 '18 at 09:10
  • @marsze I doubt that. This way, each time you update an assembly, you have to remember to update a file that's outside the assembly. It gets even more fun if you create feature-branches for different assemblies. If he really wanted to _simplify_ things, he would setup his build system to automatically apply the version info from the source control meta data (e.g. the tag name the assembly is built from). – Haukinger Oct 24 '18 at 09:15
  • @Haukinger I agree, I would prefer some automatic versioning too. But for some reason (who are we to judge?) they want to have manual control over the version numbers. And a single file is probably more handy for that. Feature branches wouldn't be a problem either, the file should merge just fine. – marsze Oct 24 '18 at 09:29
  • Thanks for the answers and the comments. What we were trying to achieve is to simplify version management. In the long run we'll probably get to the automated versioning from the git tags, but before doing that we thought as a first step to centralize versioning... – Marcomattia Mocellin Oct 24 '18 at 09:31
  • @rene im sorry but your idea won’t scale –  Oct 24 '18 at 23:10

1 Answers1

3

Using @rene's idea, setup a common AssemblyInfo as described here or elsewhere. Inside each project, define a conditional compilation symbol for the assembly name.

Then, inside your SharedAssemlyInfo.cs you could do this:

#if AssemblyName1
[assembly: AssemblyVersion("0.0.1.1")]
#elif AssemblyName2
[assembly: AssemblyVersion("1.2.4.1")]
#elif AssemblyName3
[assembly: AssemblyVersion("4.0.54.3001")]
#endif
marsze
  • 15,079
  • 5
  • 45
  • 61
  • 1
    Turning comments into answers must at least earn you an upvote from the commenter ... – rene Oct 24 '18 at 09:07