Wednesday, April 18, 2012

Remote deployment of assemblies in GAC using psexec


Hi,

I was working on my deployment automation task and in that one requirement was to deploy the assemblies on a remote machine from the build machine.

To accomplish this, I used a light weight tool called "psexec" which is available on Microsoft Technet site: http://technet.microsoft.com/en-us/sysinternals/bb897553.

In my deployment process, I knew the which are assemblies that needs to be deployed in GAC of the test server which I kept it in a folder. So I read that folder in a for loop and picked up every assembly one by one and deployed them into the GAC of the remote server. And then generate a text file which contains the list of assemblies actually deployed from that folder.

Here's the piece of code which you can refer to execute the remote deployment of assemblies into GAC.

Please note that the account which is running these scripts should have the necessary rights on the remote machine where the assemblies need to be deployed.

1) Let us say the assemblies that need to be deployed in GAC are located at:

set dlllocation=D:\AssembliesToBeGAC\

2) Let us say the text file which contains assembly list is:

set dlllist=D:\AssembliesToBeGAC\list.txt

3) The location where you have psexec executable file stored is:

set psexec=D:\AssembliesToBeGAC\psexec.exe

4) The location of gacutil.exe is:

set gacutil=D:\AssembliesToBeGAC\gacutil.exe 

Now execute the below command in a batch file:

FOR /R %dlllocation% %%G in (*.dll) DO (Echo %%G>> %dlllist%)

%psexec% -u username -p password /accepteula -i %<DeploymentServer>% %gacutil% /il %dlllist%

The above commands will actually deploy the assemblies present in folder into GAC of a remote machine.

 Cheers
Ankit

No comments:

Post a Comment