Exemple #1
0
        public async Task <ProcessRunResults> ExecuteAsync(
            string arguments,
            CancellationToken cancellationToken)
        {
            var processUtils = new ProcessUtils();

            const string npm     = "npm.cmd";
            string       npmPath = await processUtils.FindProgramAsync(npm, cancellationToken).ConfigureAwait(false);

            string directoryWithScript = Path.Combine(
                Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "NodeScript");

            try
            {
                var result = await processUtils.RunProcessAsync(npmPath, $"install {directoryWithScript}").ConfigureAwait(false);
            }
            catch (ProcessRunException ex)
            {
                Console.WriteLine(ex.ProcessStandardOutput);
                throw;
            }

            string executablePath = "node.exe";

            executablePath = await processUtils.FindProgramAsync(executablePath, cancellationToken).ConfigureAwait(false);

            string executeArgs = $"{directoryWithScript}\\index.js {arguments}";

            Console.WriteLine($"Calling: {executablePath} {executeArgs}");
            ProcessRunResults processRunResults = await processUtils.RunProcessAsync(executablePath, executeArgs, cancellationToken).ConfigureAwait(false);

            return(processRunResults);
        }
Exemple #2
0
        public async Task <ProcessRunResults> ExecuteAsync(
            string arguments,
            CancellationToken cancellationToken)
        {
            var    processUtils   = new ProcessUtils();
            string executablePath = @"mvn.cmd"; // replace with std. devops build vm location

            string pomFilePath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "pom.xml");

            executablePath = await processUtils.FindProgramAsync(executablePath, cancellationToken).ConfigureAwait(false);

            try
            {
                string compileArguments = $"-f \"{pomFilePath}\" compile";
                Console.WriteLine($"Calling:  {executablePath} {compileArguments}");
                var compileResults = await processUtils.RunProcessAsync(executablePath, compileArguments, cancellationToken).ConfigureAwait(false);
            }
            catch (ProcessRunException ex)
            {
                Console.WriteLine(ex.ProcessStandardOutput);
                throw;
            }

            string executeArguments = $"-f \"{pomFilePath}\" exec:java \"-Dexec.mainClass={ClassName}\" \"-Dexec.args={arguments}\"";

            Console.WriteLine($"Calling:  {executablePath} {executeArguments}");
            var processRunResults = await processUtils.RunProcessAsync(executablePath, executeArguments, cancellationToken).ConfigureAwait(false);

            return(processRunResults);
        }
        public async Task <ProcessRunResults> ExecuteAsync(
            string arguments,
            CancellationToken cancellationToken)
        {
            var sb = new StringBuilder();

            sb.Append($"{PythonScriptPath.EncloseQuotes()} ");
            sb.Append(arguments);
            string finalArguments = sb.ToString();

            string executablePath = "python.exe";

            var processUtils = new ProcessUtils();

            executablePath = await processUtils.FindProgramAsync(executablePath, cancellationToken).ConfigureAwait(false);

            Console.WriteLine($"Calling:  {executablePath} {finalArguments}");
            ProcessRunResults processRunResults = await processUtils.RunProcessAsync(executablePath, finalArguments, cancellationToken).ConfigureAwait(false);

            return(processRunResults);
        }