如何使用wix.sharp(我的目标 - 为服务创建MSI)在安装后运行EXE文件



im使用wix.sharp进行创建MSI。请帮助我:安装服务后如何运行EXE文件?现在,它会导致错误(当我使用MSI时)。我的应用程序开始用于Init Cofiguration服务文件。现在看起来像这样:

project.Binaries = new[]
{
    new Binary(new Id("StartAdmin"), "xxx.exe")
};
project.Actions = new WixSharp.Action[]
{
    new BinaryFileAction("StartAdmin", "Executing ...", Return.check, When.After, Step.InstallExecute, Condition.NOT_Installed)
    {
        Execute = Execute.commit
    }

谢谢。我做了我问的。我想分享结果。

using Microsoft.Deployment.WindowsInstaller;
...
var project = new Project("Application Name", GetAllEntities(releaseDir, parentDir, out service));
...
private static Dir GetDirs(string releaseDir, string parentDir, out File service)
        {
            var docDir = System.IO.Path.GetFullPath(System.IO.Path.Combine(parentDir, @"pub\doc\"));
            return new Dir(new Id("SERVICEDIR"), @"%ProgramFiles%Application",
            new Dir(new Id("INSTALLSERVICEDIR"), "App name",
                new Dir(new Id("BINSERVICEDIR"), "bin",
    ...
                    new File(string.Format("{0}{1}", releaseDir, "Admin.exe")),
...
project.AddAction(new ManagedAction(CustomActions.MyAction, Return.check, When.After, Step.InstallFinalize, Condition.NOT_Installed));
...
public class CustomActions
{
    [CustomAction]
    public static ActionResult MyAction(Session session)
    {
        System.Diagnostics.Process process = new System.Diagnostics.Process();
        process.StartInfo.FileName = string.Format("{0}\Admin.exe", session["BINSERVICEDIR"]);
        process.StartInfo.Arguments = "-n";
        process.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
        process.Start();
        process.WaitForExit();
        return ActionResult.Success;
    }
}

最新更新