{"id":3526,"date":"2012-04-16T14:09:09","date_gmt":"2012-04-16T14:09:09","guid":{"rendered":"https:\/\/test.simple-talk.com\/uncategorized\/powershell-script-for-deploying-all-assemblies-in-a-folder-to-the-gac\/"},"modified":"2016-07-28T10:50:46","modified_gmt":"2016-07-28T10:50:46","slug":"powershell-script-for-deploying-all-assemblies-in-a-folder-to-the-gac","status":"publish","type":"post","link":"https:\/\/www.red-gate.com\/simple-talk\/blogs\/powershell-script-for-deploying-all-assemblies-in-a-folder-to-the-gac\/","title":{"rendered":"PowerShell Script for Deploying All Assemblies in a Folder to the GAC"},"content":{"rendered":"<p>As a SharePoint developer, I find it a lot easier to manually deploy files to the GAC during development instead of allowing Visual Studio to do a complete retract \/ redeploy.&#160; There are tools out there like CKS Dev that give you the &#8220;Copy to GAC&#8221; option directly from a project, but I&#8217;ve found that option does not always get everything in the GAC that I want.&#160; As such, I&#8217;ve started adding a simple post-build command to copy all newly built DLLs into a &#8220;Compiled DLLs&#8221; folder in the solution root so I have a consolidated set of assemblies to deploy out to the GAC.&#160; Then I run the following PowerShell script that deploys all of the assemblies found in a folder out to the GAC:<\/p>\n<p>$gacUtilLocation = &#8220;C:Program Files (x86)Microsoft SDKsWindowsv7.0ABinx64gacutil.exe&#8221;;<\/p>\n<p>get-childitem * -include *.dll,*.exe | foreach-object {    <br \/>&#160;&#160;&#160; Write-Host &#8220;Adding&#8221; $asm.FullName    <br \/>&#160;&#160;&#160; $asm = [System.Reflection.Assembly]::LoadFile($_)    <br \/>&#160;&#160;&#160; $command = &#8220;&amp;`&#8221;{0}`&#8221;\/nologo \/i `&#8221;{1}`&#8221;&#8221; -f $gacUtilLocation,$_    <br \/>&#160;&#160;&#160; invoke-expression $command    <br \/>}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As a SharePoint developer, I find it a lot easier to manually deploy files to the GAC during development instead of allowing Visual Studio to do a complete retract \/ redeploy.&#160; There are tools out there like CKS Dev that give you the &#8220;Copy to GAC&#8221; option directly from a project, but I&#8217;ve found that&#8230;&hellip;<\/p>\n","protected":false},"author":46738,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[2],"tags":[],"coauthors":[],"class_list":["post-3526","post","type-post","status-publish","format-standard","hentry","category-blogs"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/3526","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/users\/46738"}],"replies":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/comments?post=3526"}],"version-history":[{"count":2,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/3526\/revisions"}],"predecessor-version":[{"id":42145,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/3526\/revisions\/42145"}],"wp:attachment":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/media?parent=3526"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/categories?post=3526"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/tags?post=3526"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/coauthors?post=3526"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}