Install assembly in GAC using PowerShell

We have created a new shiny assembly which is used in multiple applications. We regularly update this assembly, and add small new features in it. We want to minimize impact of these regular updates in installed projects, best option for us is to deploy it in GAC. Our regular installs were great, and never had any problems.

However we had a chance to learn something new. We wanted to update only that assembly on a client’s production environment.  Our regular ways were not suitable in this situation.

  • place assembly to %window%\assembly does not work anymore
  • place assembly to %window%\Microsoft.NET\assembly does not work either
  • and placing in %window%\assembly\GAC_MSIL does not work too

Why not use gacutil.exe, where I could find it, some options are:

  • Visual Studio 2005 C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\
  • Visual Studio 2008 C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\
  • Visual Studio 2010 C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\
  • C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin
  • C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\x64
  • C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\NETFX 4.0 Tools – .Net 4.0 32 Bit
  • C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\NETFX 4.0 Tools\x64 – .Net 4.0 64 Bit

But we neither had Visual Studio or Microsoft Windows SDK installed on that production environment.

What else we can do, PowerShell to the rescue. Here is the script to do that.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.