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.