【发布时间】:2014-08-04 05:10:28
【问题描述】:
我正在开发一个视觉工作室设置项目。到目前为止一切都很好,除了卸载。该程序没有创建自己的卸载程序,而是卸载功能位于 setup.msi 中。所以我需要做的是在安装过程中,我需要将正在运行的 setup.msi 复制到 [TARGETDIR]。我能想到的最简单的方法是使用自定义操作。不过,我对自定义操作很迷茫,我不明白它们的去向,每次我尝试编写一个代码时,它都充满了错误。查看其他问题和答案,我想出了以下内容:
[RunInstaller(true)]
public partial class CustomInstaller : System.Configuration.Install.Installer
{
public override void Install(System.Collections.IDictionary stateSaver)
{
base.Install(stateSaver);
string path = this.Context.Parameters["targetdir"];
// Do something with path.
}
}
但我不明白。我看到它是如何通过 customactiondata 传递的 targetdir。但是,RunInstaller 是未知的,System.CONfiguration.Install.Installer 也是未知的。我应该把这个 .cs 文件放在哪里让它工作?很困惑。
【问题讨论】:
标签: c# visual-studio-2010 installation setup-project custom-action