How to get the build version of a project in a visual studio 2008 deployment project

I have a deployment project in visual studio 2008 that installs several C # projects. Among other things, I would like him to write a version of the assembly of projects in the registry.

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

If not, is there a way to do this better than manually? It is important that these values ​​are correct because they are used by our software to update.

Thanks.

EDIT . I am not sure that I fully understood my question. I do not want to get this number and store it in a string. I want to write it to the registry with the deployment project registry editor (not sure if this is the official name, you can get it by right-clicking the deployment project in the solution explorer and going to View-> Registry)

+4
source share
1 answer

This should work:

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

Make sure that it is called from each main project assembly.

The GetName method returns an AssemblyName object, which has other useful information.

Edit:

You can make the assembly self-registered, which requires them to be run once to update the registry.

If this is unacceptable, you can write a plug-in for installation (and / or run a separate program). And from within this code, you need to get the file name of the assembly being installed.

+6
source

All Articles