4
我只是想创建自定义安装程序以在安装后运行代码,该代码需要安装的应用程序的路径。自定义.net安装程序使用已安装应用程序的路径的简单示例
我读了约how to create a custom installer和Custom Actions,以及什么properties are available in the installer,但我不完全知道如何从自定义安装程序代码中访问这些属性。 (甚至不要让我开始复杂的Windows Installer documentation。)
最好的答案是使用应用程序路径的自定义安装程序的完整代码。这是我到目前为止有:
using System;
using System.ComponentModel;
namespace Hawk
{
[RunInstaller(true)]
public class Installer : System.Configuration.Install.Installer
{
public Installer()
{
}
public override void Install(System.Collections.IDictionary stateSaver)
{
base.Install(stateSaver);
try
{
//TODO Find out installer path
string path = (string)stateSaver["TARGETDIR"]; // Is this correct?
// Environment.CurrentDirectory; // What is this value?
MyCustomCode.Initialize(path);
}
catch (Exception ex)
{
// message box to show error
this.Rollback(stateSaver);
}
}
}
}
有没有办法采取现有的配置备份文件在指定的路径,而安装构建? – Praveen 2013-03-22 13:30:15