In general, you can use the Gacutil tool to add an assembly (Assembly) to the Global Assembly cache (Gac,global Assembly cache). As long as the/I parameter is used, the assembly of the specified path can be added to the GAC.
However, because gacutil is not part of the. NET Framework, it is published with the Windows SDK, which leads to the installation of. NET in the machine, but may not find gacutil.
In PowerShell, we can use it directly. NET class library to handle this, without having to pass the gacutil. The specific code is as follows:
1 2 3 4 |
[Reflection.assembly]::loadwithpartialname ("System.EnterpriseServices") > $null [ System.EnterpriseServices.Internal.Publish] $publish = New-object System.EnterpriseServices.Internal.Publish $ Publish. Gacinstall ("<dll full path >") |
In addition, System.EnterpriseServices.Internal.Publish also provides functionality similar to RegAsm, which can be queried for MSDN.