[英]Deploy multiple dll files into gac without gacutil
所以,問題是我需要將多個C#dll部署到多台計算機上的gac中。 這些沒有 gacutil ,我希望它保持這種狀態。 如何像輕松運行exe或批處理文件那樣輕松地部署這些文件? 為gac部署創建可執行文件是否可行/個好主意,如何做到這一點?
PS。 我只有MS Visual Studio Express
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): $_"
}
}
您的解決方案在組裝System.EnterpriseServices.Internal中
那里已經有人回答: C#如何在沒有GacUtil的情況下在GAC中注冊程序集?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.