Saturday, January 26, 2013

Refresh GAC using Powershell

Scenario:
Refreshing GAC is always a painful thing.
Do IISReset / remove old stuff / put new one. Can we automate it ?

Solution:
Certainly.. mighty power-shell can do it easily

If you are running on new machine - you might need to relax executing policy

Set-ExecutionPolicy Unrestricted
Code:
iisreset /stop

Set-Alias Gacutil "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin\gacutil.exe"

Gacutil /uf EntLibContrib.Data.OdpNet
Gacutil /i "MS ENT dlls\EntLibContrib.Data.OdpNet.dll"

Gacutil /uf Microsoft.Practices.EnterpriseLibrary.Caching
Gacutil /i "MS ENT dlls\Microsoft.Practices.EnterpriseLibrary.Caching.dll"

Gacutil /uf Microsoft.Practices.EnterpriseLibrary.Common
Gacutil /i "MS ENT dlls\Microsoft.Practices.EnterpriseLibrary.Common.dll"

Gacutil /uf Microsoft.Practices.EnterpriseLibrary.Data
Gacutil /i "MS ENT dlls\Microsoft.Practices.EnterpriseLibrary.Data.dll"

Gacutil /uf Microsoft.Practices.EnterpriseLibrary.Logging
Gacutil /i "MS ENT dlls\Microsoft.Practices.EnterpriseLibrary.Logging.dll"

Gacutil /uf Microsoft.Practices.ServiceLocation
Gacutil /i "MS ENT dlls\Microsoft.Practices.ServiceLocation.dll"

Gacutil /uf Microsoft.Practices.Unity.Configuration
Gacutil /i "MS ENT dlls\Microsoft.Practices.Unity.Configuration.dll"

Gacutil /uf Microsoft.Practices.Unity
Gacutil /i "MS ENT dlls\Microsoft.Practices.Unity.dll" 

Gacutil /uf Microsoft.Practices.Unity.Interception.Configuration
Gacutil /i "MS ENT dlls\Microsoft.Practices.Unity.Interception.Configuration.dll"

Gacutil /uf Microsoft.Practices.Unity.Interception
Gacutil /i "MS ENT dlls\Microsoft.Practices.Unity.Interception.dll" 

Gacutil /uf Telerik.Web.Design
Gacutil /i "Telerik.Web.Design.dll"

Gacutil /uf Telerik.Web.UI
Gacutil /i "Telerik\Telerik.Web.UI.dll" 

Gacutil /uf Telerik.Reporting
Gacutil /i "Telerik\Telerik.Reporting.dll"

Gacutil /uf Telerik.Web.UI.Skins
Gacutil /i "Telerik\Telerik.Web.UI.Skins.dll"

iisreset /start