views:

185

answers:

1

Hello.

I have a deployment project in visual studio 2008 that installs several C# projects. Among other things, I'd like it to write projects assembly version to registry.

Is there a way to automatically find out whats the projects assembly version (written in AssemblyInfo.cs) and write that as value of a registry property?

If not, is there any way to do this better than by hand? It is important that these values are correct because they are used by our updating software.

Thank you.

EDIT: I'm not sure I was completely clear in my question. I don't want to get this number and store it to a string. I want to write it to registry with Deployment Projects Registry Editor (not sure if that's the official name, you can get to it by right clicking the deployment project in solution explorer and navigating to View->Registry)

+2  A: 

This should work:

 Assembly.GetExecutingAssembly().GetName().Version.ToString();

Make sure this is called from each Projects main assembly.

The GetName method returns an AssemblyName object that has other useful info as well.

Edit:

You could make the assemblies self-registering, that requires them to be run once to update the registry.

If that is not acceptable can write a plugin for setup (and/or run a separate program). And from within that code you need to get the filename of the assembly being installed.

Henk Holterman
I'm not sure I was completely clear in my question. I don't want to get this number and store it to a string. I want to write it to registry with Deployment Projects Registry Editor (not sure if that's the official name, you can get to it by right clicking the deployment project in solution explorer and navigating to View->Registry)
Rekreativc