Thursday, September 12, 2013

Use PowerShell to GAC a FIM Workflow DLL without gacutil.exe

Sometimes you just don’t have the right paths, and can’t be bothered to search for gacutil.exe, or maybe you want to automate the operation without needing gacutil.exe.

Here’s how to do it from PowerShell:

###

### Re-GAC the WF DLL

###

$assemblyFileName = 'c:\sd\MySuperCoolFimActivityLibrary.dll'

if (-not (Test-Path $assemblyFileName))

{

    Throw "Unable to find the DLL: $assemblyFileName"

}

$fullFileName = dir $assemblyFileName | select -expand fullname

[Reflection.Assembly]::LoadWithPartialName("System.EnterpriseServices") | Out-Null

[System.EnterpriseServices.Internal.Publish] $publish = new-object System.EnterpriseServices.Internal.Publish

 

### This method call will never return errors or exceptions

### On failure however it does put an entry into the event viewer

$publish.GacInstall($fullFileName)

 

### Changes to WF DLLs Require a FIM Service restart

Restart-Service FimService

 

No comments: