Ejemplo n.º 1
0
        protected Process LaunchImplementation()
        {
            if (Requirements.Command == "")
            {
                throw new OptionException(Resources.NoRunWithEmptyCommand, "--command");
            }

            using (CreateRunHook())
            {
                try
                {
                    return(Executor.Start(Selections, AdditionalArgs.ToArray()));
                }
                #region Error handling
                catch (KeyNotFoundException ex)
                {
                    // Gracefully handle broken external selections
                    if (SelectionsDocument)
                    {
                        throw new InvalidDataException(ex.Message, ex);
                    }
                    else
                    {
                        throw;
                    }
                }
                #endregion
            }
        }
Ejemplo n.º 2
0
        protected Process LaunchImplementation()
        {
            if (Requirements.Command == "")
            {
                throw new OptionException(Resources.NoRunWithEmptyCommand, "command");
            }

            using (CreateRunHook())
                return(Executor.Start(Selections, AdditionalArgs.ToArray()));
        }
Ejemplo n.º 3
0
        protected Process?LaunchImplementation()
        {
            Debug.Assert(Selections != null);

            if (Requirements.Command == "")
            {
                throw new OptionException(Resources.NoRunWithEmptyCommand, "command");
            }

            return(Executor.Inject(Selections, _overrideMain)
                   .AddWrapper(_wrapper)
                   .AddArguments(AdditionalArgs.ToArray())
                   .Start());
        }
Ejemplo n.º 4
0
    /// <inheritdoc/>
    public override ExitCode Execute()
    {
        if (Requirements.Command == "")
        {
            throw new OptionException(Resources.NoRunWithEmptyCommand, "command");
        }

        Solve();

        DownloadUncachedImplementations();

        Handler.CancellationToken.ThrowIfCancellationRequested();
        Handler.DisableUI();

        var process = Executor.Inject(Selections, _overrideMain)
                      .AddWrapper(_wrapper)
                      .AddArguments(AdditionalArgs.ToArray())
                      .SetEnvironmentVariable(ZeroInstallEnvironment.FeedUriName, Requirements.InterfaceUri.ToStringRfc())
                      .SetCallbackEnvironmentVariables()
                      .Start();

        CloseUI(process);

        BackgroundUpdate();
        BackgroundSelfUpdate();

        if (process == null)
        {
            Log.Warn("No process launched");
            return(ExitCode.OK);
        }
        else if (_noWait)
        {
            Log.Debug("Not waiting for program to exit");
            return(WindowsUtils.IsWindows ? (ExitCode)process.Id : ExitCode.OK);
        }
        else
        {
            Log.Debug("Waiting for program to exit");
            return((ExitCode)process.WaitForExitCode());
        }
    }
Ejemplo n.º 5
0
    /// <inheritdoc/>
    public override ExitCode Execute()
    {
        if (Requirements.Command == "")
        {
            throw new OptionException(Resources.NoRunWithEmptyCommand, "command");
        }

        Solve();

        DownloadUncachedImplementations();

        Handler.CancellationToken.ThrowIfCancellationRequested();
        Handler.DisableUI();

        var process = Executor.Inject(Selections, _overrideMain)
                      .AddWrapper(_wrapper)
                      .AddArguments(AdditionalArgs.ToArray())
                      .Start();

        Handler.CloseUI();

        BackgroundUpdate();
        BackgroundSelfUpdate();

        if (process == null)
        {
            return(ExitCode.OK);
        }
        if (_noWait)
        {
            return(WindowsUtils.IsWindows ? (ExitCode)process.Id : ExitCode.OK);
        }
        else
        {
            Log.Debug("Waiting for application to exit");
            process.WaitForExit();
            return((ExitCode)process.ExitCode);
        }
    }