简体   繁体   English

在没有gacutil的情况下将多个dll文件部署到gac中

[英]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. 所以,问题是我需要将多个C#dll部署到多台计算机上的gac中。 These does not have the gacutil and I would prefer if it stayed that way. 这些没有 gacutil ,我希望它保持这种状态。 How would one go about deploying these files easily, like just running a exe or batch file? 如何像轻松运行exe或批处理文件那样轻松地部署这些文件? Is it possible/good idea to create a executable file for gac deployment and how could this be done? 为gac部署创建可执行文件是否可行/个好主意,如何做到这一点?

Ps. PS。 I do only have the ms visual studio express 我只有MS Visual Studio Express

PowerShell is your friend: PowerShell是您的朋友:

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): $_"
    }
}

Your solution is in the assembly System.EnterpriseServices.Internal 您的解决方案在组装System.EnterpriseServices.Internal中

It has already been answered there : C# how to register assembly in the GAC without GacUtil? 那里已经有人回答: C#如何在没有GacUtil的情况下在GAC中注册程序集?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM