Sta*_*ker 13 c# windows setup-deployment winforms
我正在部署一个应用程序,在用户选择安装应用程序的位置后的安装过程中,我希望得到这条路径; 我已经进行了自定义操作,但我不知道如何获取将要安装的应用程序路径!
这是Windows Forms,我正在使用Visual Studio 2010"C#"进行开发.
我正在使用默认的部署工具......
任何的想法?
提前致谢...
Mar*_*own 36
您的自定义操作所在的类应继承自System.Configuration.Installer.Installer.它有一个名为Context的参数,它有一个Parameters字典.该字典包含许多有关安装的有用变量,您可以添加一些.
在"自定义操作"窗格中将自定义安装程序添加到安装项目后.选择Install操作并将CustomActionData属性设置为:
/targetdir="[TARGETDIR]\"
Run Code Online (Sandbox Code Playgroud)
然后你可以访问这样的路径:
[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.
}
}
Run Code Online (Sandbox Code Playgroud)