Update a Dll in the GAC From the Command Line
I’ve blogged before on how to Easily add a dll to the GAC, but that involves two instances of Windows Explorer and the mouse.
It would be quicker and easier to use the command line to update a dll in the GAC. You can do this with the Global Assembly Cache Tool gacutil, but this is only present if you have the .net SDK or Windows SDK installed. This is going to be the case with your development machine, but you don’t really want to be installing it on all your test servers.
To get round this I knocked up a quick utility which will remove an existing version of a dll from the GAC and then install the latest version. The code is:
public class GacInstall
public static void Main(string arguments)
string assemblyPath = arguments;
Publish publish = new Publish();
catch (Exception e)
You can then use it by passing it the dll you want as a command line parameter e.g.
Assuming that MyUpdatedCode.dll is in the same directory.
Combined with my last tip Recycle An Individual Application Pool From The Command Line you can now write a bat or cmd file to replace the dll in the GAC and recycle the application pool with 2 key presses: The up arrow key and then return.
Managing Director / Founder
Richard started SalamanderSoft in 2007 after a successful career as a software developer. Wanting to start his own company and with experience in integrating school systems he set out to build the best integration system for schools and to exceed customer expectations. He starting out on his own, doing all the coding, support and sales until finally the growing number of customers meant he needed to start growing the team. He is still heavily involved in coding the core Integration Suite product in addition to running the company and being the first point of contact for prospective customers.