Example #1
0
        /// <summary>
        /// Executes the specified Command Prompt command in a dialog.
        /// </summary>
        /// <param name="owner">Any object that implements IWin32Window that represents the top-level window that will own the modal dialog box.</param>
        /// <param name="workingDirectory">The working directory for the command.</param>
        /// <param name="path">The path where the command should be executed.</param>
        /// <param name="command">The command to execute.</param>
        /// <param name="commandArguments">The command arguments. <see cref="CommandArgument"/></param>
        /// <returns>The return value of the specified command.</returns>
        public static int ExecuteCommand(IWin32Window owner, string workingDirectory, string path, string command, params CommandArgument[] commandArguments)
        {
            var form = new FormDialogCommandShell
            {
                Command          = command,
                CommandArguments = new List <CommandArgument>(commandArguments),
                CommandPath      = path,
                WorkingDirectory = workingDirectory,
            };

            form.ShowDialog(owner);
            using (form)
            {
                return(form.CommandResult);
            }
        }
Example #2
0
 private void btSetApiKey_Click(object sender, EventArgs e)
 {
     FormDialogCommandShell.ExecuteCommand(this, Paths.AppInstallDir, Paths.AppInstallDir, "nuget.exe",
                                           new CommandArgument("setapikey", tbGitHubPackagesApiKey.Text, true),
                                           new CommandArgument("-source", "https://nuget.pkg.github.com/" + tbGitHubPackagesUserName.Text + "/index.json"));
 }