# Thursday, 30 March 2006

The product I spend most of my time working on (our SDK) gets installed in the GAC.  The problem with that is that I often find myself having to switch between functional testing of client apps that use the SDK (and need it to be GAC installed) and my own unit testing.  In the past, that’s meant that every time I need to do unit testing of changes, I had to uninstall the version in the GAC, since if they ran from the GAC, there were no PDB files, and hence no debugging. 

Thanks to Explorer hiding the GAC directories from us, you have to do it from the command line or using some other tool.  I hate writing batch files, so I thought I’d try it with Monad instead.  I’ve been playing with it for a couple of weeks since Scott turned me on to it, and I’m digging it pretty seriously. 

The script below assumes that you are running it from a directory that includes both the DLL and PDB files.


$pdbfiles = get-childitem | where {$_.name.EndsWith("pdb")}

foreach ($pdb in $pdbfiles)


    $dllPath = [System.IO.Path]::Combine([System.IO.Path]::GetDirectoryName($pdb.FullName),[System.IO.Path]::GetFileNameWithoutExtension($pdb.FullName)) + ".dll"




        $dll = [System.Reflection.Assembly]::LoadFile($dllpath)


        $version = $dll.GetName().Version


        $token = $dll.GetName().GetPublicKeyToken()


        if($token -ne $null)



            $tokenStr = ""

            foreach($b in $token)


                if ([int]$b -lt 16)


                    $tokenStr += "0";


                $tokenStr += [Convert]::ToString($b,16)



            $d = $version.ToString() + "__" + $tokenStr

            $installPath = [System.IO.Path]::Combine("c:\windows\assembly\gac",([System.IO.Path]::GetFileNameWithoutExtension($dllPath)))

            $installPath = [System.IO.Path]::Combine($installPath,$d);

            $installPath = [System.IO.Path]::Combine($installPath,[System.IO.Path]::GetFileName($pdb))










Thursday, 30 March 2006 15:42:37 (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  |