1

我正在使用 WIX.sharp 创建 msi。请帮助我:安装服务后如何运行exe文件?现在它会导致错误(当我使用我的 msi 时)。我的应用程序启动服务的初始化配置文件。现在看起来像这样:

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
    }
4

1 回答 1

0

谢谢。我按照我的要求做了。我想分享结果。

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;
    }
}
于 2019-03-27T08:38:24.783 回答