A useful tip from Mike Belshe on installing asssemblies into the GAC from code.
Combining that with an Installer class allows you to add that capability to your installation. Choose any of the libraries that you are deploying and add a new Installer class. Override the following two methods
{
base .Install (stateSaver);
string strAssemblyFile = base .Context.Parameters["name"].ToString();
System.EnterpriseServices.Internal.Publish foo = new System.EnterpriseServices.Internal.Publish();
foo.GacInstall(strAssemblyFile);
}
public override void Uninstall(IDictionary savedState)
{
string strAssemblyFile = base .Context.Parameters["name"].ToString();
System.EnterpriseServices.Internal.Publish foo = new System.EnterpriseServices.Internal.Publish();
foo.GacRemove(strAssemblyFile);
base .Uninstall (savedState);
}
Then in your installer project, open the "Custom Actions" and add a new action to the install and uninstall nodes, selecting the assembly that you added the installer class to.
Then you can install any other assembly that you are deploying to the GAC by passing it's name to the CustomActionData, and you can have as many custom actions as you need on the same assembly.
本文介绍了一种将程序集安装到全局程序缓存(GAC)的方法。通过创建一个自定义的Installer类并覆盖Install和Uninstall方法,可以实现在安装过程中自动将程序集部署到GAC的功能。
730

被折叠的 条评论
为什么被折叠?



