views:

603

answers:

2

During a setup creation process, I am planning to do the following (within a C# Script):

  1. Read the AssemblyVersion and AssemblyFileVersion attribute values of one DLL.
  2. Iterate all DLLs and executables in the project and apply those version to their AssemblyVersion and AssemblyFileVersion attribute values.

Question now is: How to do step 2?

I successfully can do step 1, but for step 2 I don't see a real start point. What I probably have to do is to use some native P/Invoke methods since the attributes directly modify the version information resource information of a DLL/executable.

Any hints on this?

Thanks, Uwe

+5  A: 

Why don't you, during build process, read the AssemblyVersion and AssemblyFileVersion of one DLL, and save it back to other csproject's AssemblyInfo.cs, only then compile it?

As a matter of fact, I don't know whether it is possible to modify the DLL file directly, without resorting to something fanciful.

Or alternatively, make sure that all your DLLs share one common AssemblyInfo.cs. You can do this by adding the AssemblyInfo.cs as "Add As Link" when you add a new item in csproject. In this way when you do a compilation, all the DLLs will share the same AssemblyInfo.cs, and thus output the same AssemblyVersion.

Ngu Soon Hui
yes, that would be **much** easier! Set the version numbers straight at build time, e.g. using a continuous integration build server
marc_s
That would be the right way, changing the compiled files break clean information line between code and binaries.
BeowulfOF
Thank you very much, I do like the idea of sharing the AssemblyInfo.cs file!
Uwe Keim
A: 

If you have access to the sources, take the advice from Ngu Soon Hui

If you don't, you might be in trouble. Possibly you can disassemble with ILDASM and reassemble with ILASM. But this won't work out for strong-named assemblies.

The Chairman