Automating Remote GAC Installs On Build

When working with SharePoint, you’ll find yourself working with the GAC quite often during development.

If you’ve seen the light and you’re working with SharePoint on a VM, one tricky problem is how to update the GAC using a post-build event.  The following is a little script that I use:

The batch script makes use of Sysinternal’s PsExec.  I’ve included the binary executable in my solution tree under the directory “Tools”.

The script only has one assumption: the VM (or remote machine, really) is sharing the c:\temp directory (okay, and that the path to gacutil.exe has been added to the remote machine’s PATH environment variable).  Here’s a breakdown of the logic:

  1. The first step is to check if the directory exists and can be reached.  If not, we go to the end and show a notice about sharing the directory.
  2. If the directory is shared, the output dll from the build is copied to the shared directory using plain old XCOPY.
  3. Once it’s copied over, we use PsExec to execute gacutil on the VM (or remote machine).  The -w argument specifies the working directory on the remote machine.


You may also like...