Thursday, March 28, 2019

PowerShell to Add or Remove assembly to GAC

Hi All,

Very often during the BizTalk Development we require to register the Assembly in GAC. This tasks seems to be very easy on your development box but when you are going to deploy to TEST or STAG environment, you will find yourself in difficulties when you don't find Visual Studio command prompt!!

To ease such situation in Windows have a nice feature of PowerShell using which one can deploy the Assembly in GAC.

Similar way to Remove the Assembly from GAC use the method GACRemove()



Here is the snippet,


#Note you should be running PowerShell as an Admin

[System.Reflection.Assembly]::Load("System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")           

$publish = New-Object System.EnterpriseServices.Internal.Publish           

$publish.GacInstall("C:\YourDLLPath\To\YourDLL.dll")



#If installing into the GAC on a server hosting web applications in Internet Information Services, you need to restart IIS for the applications to pick up the change.

#Uncomment the below line if necessary...



#iisreset




Hope this Helps!!!!!!


HTH