示例#1
0
 /// <summary>
 /// Executes nunit against the specified assemblies.
 /// </summary>
 /// <param name="assemblyPaths">The assemblies</param>
 /// <param name="options">Additional options: path (path to unit)</param>
 public static void nunit(string[] assemblyPaths, Hash options)
 {
     string path = options.ObtainAndRemove("path", "lib\\nunit\\nunit-console.exe");
     foreach (var assembly in assemblyPaths) {
         IOFunctions.exec(path, "\"" + assembly + "\"");
     }
 }
示例#2
0
        /// <summary>
        /// Executes the specified program with the specified arguments.  You can also
        /// specify the working directory of the command by providing the hash option "WorkingDir"
        /// </summary>
        /// <param name="command">The command to execute</param>
        /// <param name="args">Additional args</param>
        /// <param name="options">A hash of options to set on the process (like WorkingDir)</param>
        public static void exec(string command, string args, Hash options)
        {
            string workingDir = options.ObtainAndRemove("WorkingDir", ".");
            bool ignoreNonZeroExitCode = options.ObtainAndRemove("IgnoreNonZeroExitCode", false);
            var psi = new ProcessStartInfo(command, args) {
                                                          	WorkingDirectory = workingDir,
                                                          	UseShellExecute = false,
                                                          	RedirectStandardError = true
                                                          };
            var process = Process.Start(psi);
            process.WaitForExit();
            var exitCode = process.ExitCode;

            if (exitCode != 0 && ignoreNonZeroExitCode == false) {
                throw new ExecutionFailedException(exitCode);
            }
        }
示例#3
0
        /// <summary>
        /// Executes msbuild
        /// </summary>
        /// <param name="file">The path to the file to build</param>
        /// <param name="options">Hash of options</param>
        public static void msbuild(string file, Hash options)
        {
            string frameworkVersion = options.ObtainAndRemove("frameworkVersion", "3.5");
            string configuration = options.ObtainAndRemove("configuration", "debug");
            string targets = options.ObtainAndRemove("targets", "build");
            string verbosity = options.ObtainAndRemove("verbosity", "minimal");

            string msbuildDir = UtilityFunctions.env("windir") + "\\microsoft.net\\framework\\v" + frameworkVersion +
                                "\\msbuild.exe";
            string args = file + " /p:Configuration=" + configuration + " /t:" + targets + " /v:" + verbosity;

            foreach (var key in options.Keys) {
                args += " /p:" + key + "=" + options[key];
            }

            IOFunctions.exec(msbuildDir, args);
        }
示例#4
0
 /// <summary>
 /// Executes the specified program with the specified arguments.  You can also
 /// specify the working directory of the command by providing the hash option "WorkingDir"
 /// </summary>
 /// <param name="command">The command to execute</param>
 /// <param name="args">Additional args</param>
 /// <param name="options">A hash of options to set on the process (like WorkingDir)</param>
 public static void exec(string command, string args, Hash options)
 {
     string workingDir = options.ObtainAndRemove("WorkingDir", ".");
     var psi = new ProcessStartInfo(command, args) {
                                                       WorkingDirectory = workingDir,
                                                       UseShellExecute = false,
                                                       RedirectStandardError = true
                                                   };
     var process = Process.Start(psi);
     process.WaitForExit();
 }
示例#5
0
        /// <summary>
        ///   Executes the specified program with the specified arguments.  You can also
        ///   specify the working directory of the command by providing the hash option "WorkingDir"
        /// </summary>
        /// <param name="command">
        ///   The command to execute
        /// </param>
        /// <param name="args">Additional args</param>
        /// <param name="options">
        ///   A hash of options to set on the process (like WorkingDir)
        /// </param>
        public static void exec(string command, string args, Hash options)
        {
            Exec exec = new Exec();
            exec.ExeName = command;
            exec.Output = (options.ContainsKey("Output")) ? new FileInfo(options.ObtainAndRemove("Output", "")) : null;
            exec.Execute(args, options);
            //string workingDir = options.ObtainAndRemove("WorkingDir", ".");
            //bool ignoreNonZeroExitCode = options.ObtainAndRemove("IgnoreNonZeroExitCode", false);
            //var psi = new ProcessStartInfo(command, args) {
            //    WorkingDirectory = workingDir,
            //    UseShellExecute = false,
            //    RedirectStandardError = true
            //};
            //var process = Process.Start(psi);
            //process.WaitForExit();
            //var exitCode = process.ExitCode;

            //if (exitCode != 0 && ignoreNonZeroExitCode == false) {
            //    var errortext = process.StandardError.ReadAllAsString();
            //    throw new ExecutionFailedException(exitCode, errortext);
            //}
        }
示例#6
0
        public void Execute(string args, Hash options)
        {
            Thread outputThread = null;

            string workingDir = options.ObtainAndRemove("WorkingDir", ".");
            bool ignoreNonZeroExitCode = options.ObtainAndRemove("IgnoreNonZeroExitCode", false);
            var psi = new ProcessStartInfo(_exeName, args)
            {
                WorkingDirectory = workingDir,
                UseShellExecute = false,
                RedirectStandardError = true,
                RedirectStandardOutput = (Output != null) ? true : false
            };
            var process = Process.Start(psi);

            if (Output != null) {
                outputThread = new Thread(StreamReaderThread_Output);
                _stdOut = process.StandardOutput;
                outputThread.Start();
            }

            process.WaitForExit();

            if (Output != null) {
                outputThread.Join(2000);
            }

            var exitCode = process.ExitCode;

            if (exitCode != 0 && ignoreNonZeroExitCode == false)
            {
                var errortext = process.StandardError.ReadAllAsString();
                throw new ExecutionFailedException(exitCode, errortext);
            }
        }