VS2005 Post Build Events: adding an assembly to the GAC

An assembly must be strongly named before it can be added to the GAC. The correct way to do this in visual studio 2005 is specify the path to a strong name key file (snk file – generated with sn -k ) in the signing tab of the projects properties dialog.

Once this is done, under the Build Events tab of the projects properties dialog, specify the following to install the assembly to the GAC on a successful build:
"C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\gacutil.exe" /i "$(TargetPath)"

Note that you do not need to worry about uninstalling the existing assembly from the GAC before installing the new one – the above command takes care of this.

Also Note – make sure that you set the AssemblyVersion in AssemblyInfo.css to 1.0.0.0 or equivalent. If you leave stars in the AssemblyVersion, the assembly will get installed multiple times in the GAC (for each version).

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>