Robert Erneborg
Robert Erneborg

Reputation: 69

Deploy multiple dll files into gac without gacutil

So, the thing is I have several C# dlls that need to be deployed into gac on several machines. These does not have the gacutil and I would prefer if it stayed that way. How would one go about deploying these files easily, like just running a exe or batch file? Is it possible/good idea to create a executable file for gac deployment and how could this be done?

Ps. I do only have the ms visual studio express

Upvotes: 0

Views: 3417

Answers (2)

David Brabant
David Brabant

Reputation: 43459

PowerShell is your friend:

function Gac-Util
{
    param (
        [parameter(Mandatory = $true)][string] $assembly
    )

    try
    {
        $Error.Clear()

        [Reflection.Assembly]::LoadWithPartialName("System.EnterpriseServices") | Out-Null
        [System.EnterpriseServices.Internal.Publish] $publish = New-Object System.EnterpriseServices.Internal.Publish

        if (!(Test-Path $assembly -type Leaf) ) 
            { throw "The assembly $assembly does not exist" }

        if ([System.Reflection.Assembly]::LoadFile($assembly).GetName().GetPublicKey().Length -eq 0 ) 
            { throw "The assembly $assembly must be strongly signed" }

        $publish.GacInstall($assembly)

        Write-Host "`t`t$($MyInvocation.InvocationName): Assembly $assembly gacced"
    }

    catch
    {
        Write-Host "`t`t$($MyInvocation.InvocationName): $_"
    }
}

Upvotes: 3

Ronan Lamour
Ronan Lamour

Reputation: 1476

Your solution is in the assembly System.EnterpriseServices.Internal

It has already been answered there : C# how to register assembly in the GAC without GacUtil?

Upvotes: 1

Related Questions