Microsoft Visual Studio – Web development quickie tip: Quick GAC deployment

I’ve been across this one so many times before, so I’m adding this entry to remind myself how to automatically deploy compiled libraries to the GAC and recycle the application pool after a successful compilation in Visual Studio 2005/2008:

Add this on the post build events of the Class Library project for quick GAC deployment

“C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\gacutil” -i “$(TargetPath)” | C:\Recycle.vbs

Then create a VB Script file using Notepad in location C:\Recycle.vbs:

strAppPoolName = “DefaultAppPool”
strComputer = “.”
Set objWMIService = GetObject _
(“winmgmts:{authenticationLevel=pktPrivacy}\\” _
& strComputer & “\root\microsoftiisv2”)

Set colItems = objWMIService.ExecQuery _
(“Select * From IIsApplicationPool Where Name = ” & _
“‘W3SVC/AppPools/” &strAppPoolName & “‘”)

For Each objItem in colItems
objItem.Recycle
Next

Wscript.echo “Recycle Completed”

Change the value of the variable “strAppPoolName” to the name of the application pool that needs recycling.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: