Ejemplo n.º 1
0
 private static IProcess StartProcess(GitSettings toolSettings, ProcessSettings processSettings)
 {
     return(ProcessTasks.StartProcess(
                toolSettings.ToolPath,
                toolSettings.Arguments,
                toolSettings.WorkingDirectory,
                processSettings?.EnvironmentVariables,
                processSettings?.ExecutionTimeout,
                processSettings?.RedirectOutput ?? false));
 }
Ejemplo n.º 2
0
        /// <summary><p>dupFinder is a free command line tool that finds duplicates in C# and Visual Basic .NET code - no more, no less. But being a JetBrains tool, dupFinder does it in a smart way. By default, it considers code fragments as duplicates not only if they are identical, but also if they are structurally similar, even if they contain different variables, fields, methods, types or literals. Of course, you can configure the allowed similarity as well as the minimum relative size of duplicated fragments.</p><p>For more details, visit the <a href="https://www.jetbrains.com/help/resharper/dupFinder.html">official website</a>.</p></summary>
        public static void DupFinder(Configure <DupFinderSettings> configurator = null, ProcessSettings processSettings = null)
        {
            var toolSettings = configurator.InvokeSafe(new DupFinderSettings());

            PreProcess(toolSettings);
            var process = ProcessTasks.StartProcess(toolSettings, processSettings);

            process.AssertZeroExitCode();
            PostProcess(toolSettings);
        }
Ejemplo n.º 3
0
    private void RunCodeInRoot(string toolPath, string arguments)
    {
        var proc = ProcessTasks.StartProcess(toolPath,
                                             workingDirectory: RootDirectory,
                                             arguments: arguments
                                             );

        proc.WaitForExit();
        proc.AssertZeroExitCode();
    }
Ejemplo n.º 4
0
        /// <summary><p>GitLink makes symbol servers obsolete which saves you both time with uploading source files with symbols and the user no longer has to specify custom symbol servers (such as symbolsource.org). The advantage of GitLink is that it is fully customized for Git. It also works with GitHub or BitBucket urls so it does not require a local git repository to work. This makes it perfectly usable in continuous integration servers such as Continua CI. Updating all the pdb files is very fast. A solution with over 85 projects will be handled in less than 30 seconds. When using GitLink, the user no longer has to specify symbol servers. The only requirement is to ensure the check the Enable source server support option in Visual Studio.</p><p>For more details, visit the <a href="https://github.com/GitTools/GitLink/">official website</a>.</p></summary>
        public static IReadOnlyCollection <Output> GitLink3(Configure <GitLink3Settings> configurator = null)
        {
            var toolSettings = configurator.InvokeSafe(new GitLink3Settings());

            PreProcess(ref toolSettings);
            var process = ProcessTasks.StartProcess(toolSettings);

            process.AssertZeroExitCode();
            return(process.Output);
        }
Ejemplo n.º 5
0
        private static IReadOnlyCollection <Output> StartProcess([NotNull] ToolSettings settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }
            var process = ProcessTasks.StartProcess(settings);

            process.AssertZeroExitCode();
            return(process.Output);
        }
Ejemplo n.º 6
0
        /// <summary><p>GitVersion is a tool to help you achieve Semantic Versioning on your project.</p><p>For more details, visit the <a href="http://gitversion.readthedocs.io/en/stable/">official website</a>.</p></summary>
        public static GitVersion GitVersion(Configure <GitVersionSettings> configurator = null, ProcessSettings processSettings = null)
        {
            var toolSettings = configurator.InvokeSafe(new GitVersionSettings());

            PreProcess(toolSettings);
            var process = ProcessTasks.StartProcess(toolSettings, processSettings);

            process.AssertZeroExitCode();
            PostProcess(toolSettings);
            return(GetResult(process, toolSettings, processSettings));
        }
Ejemplo n.º 7
0
        private static void RunScript(string file, string arguments = null)
        {
            file = file.DoubleQuoteIfNeeded();

            var process = ProcessTasks.StartProcess(
                ScriptHost,
                EnvironmentInfo.IsWin
                    ? $"-File {file} {arguments}"
                    : $"{file} {arguments}");

            process.AssertZeroExitCode();
        }
Ejemplo n.º 8
0
        private static IProcess StartProcess(OpenCoverSettings toolSettings, ProcessSettings processSettings = null)
        {
            var testAction        = toolSettings.TestAction.NotNull("testAction != null");
            var capturedStartInfo = ProcessTasks.CaptureProcessStartInfo(testAction);

            toolSettings = toolSettings
                           .SetTargetPath(capturedStartInfo.ToolPath)
                           .SetTargetArguments(capturedStartInfo.Arguments)
                           .SetTargetDirectory(capturedStartInfo.WorkingDirectory);

            return(ProcessTasks.StartProcess(toolSettings, processSettings));
        }
Ejemplo n.º 9
0
 private static IProcess StartProcess(UnityBaseSettings unitySettings)
 {
     try
     {
         return(ProcessTasks.StartProcess(unitySettings));
     }
     catch (Exception)
     {
         AssertWatcherStopped();
         throw;
     }
 }
Ejemplo n.º 10
0
    public IIS(params string[] appPoolNames)
    {
        if (File.Exists(Appcmd))
        {
            this.appPoolNames = appPoolNames;

            foreach (var appPoolName in this.appPoolNames)
            {
                ProcessTasks.StartProcess(Appcmd, @$ "STOP APPPOOL " "{appPoolName}" "").WaitForExit();
            }
        }
    }
Ejemplo n.º 11
0
        private static void Initialize(string workingDirectory)
        {
            var dotnet = ToolPathResolver.TryGetEnvironmentExecutable("DOTNET_EXE") ??
                         ToolPathResolver.GetPathExecutable("dotnet");
            var output   = ProcessTasks.StartProcess(dotnet, "--info", workingDirectory, logOutput: false).AssertZeroExitCode().Output;
            var basePath = (PathConstruction.AbsolutePath)output
                           .Select(x => x.Text.Trim())
                           .Single(x => x.StartsWith("Base Path:"))
                           .TrimStart("Base Path:").Trim();

            EnvironmentInfo.SetVariable("MSBUILD_EXE_PATH", basePath / "MSBuild.dll");
        }
Ejemplo n.º 12
0
        private bool MoveProjectStepB(VisualStudioProject project)
        {
            // Now add it back to project with new location
            string   addParam = Path.Combine(project.NewPath, project.Namecsproj);
            IProcess sln      = ProcessTasks.StartProcess(DotNetPath, "sln " + ExpectedSolutionPath + " add " + addParam, logOutput: true);

            sln.AssertWaitForExit();
            ControlFlow.Assert(sln.ExitCode == 0, "Failed to re-add Project: " + project.Name + " to solution so we could complete the move");

            Logger.Success("Project: {0} successfully relocated into proper new directory layout.", project.Name);
            return(true);
        }
Ejemplo n.º 13
0
        public static string StartProcess(string processPath, string arguments, string workingDirectory = null)
        {
            var process = ProcessTasks.StartProcess(processPath, arguments, workingDirectory, null, null, true);

            process?.WaitForExit();
            var result = string.Join(System.Environment.NewLine, process?.Output.Select(x => x.Text));

            if (process?.ExitCode == 1)
            {
                throw new System.Exception(result);
            }
            return(result);
        }
Ejemplo n.º 14
0
        private static IProcess StartProcess(InspectCodeSettings toolSettings, ProcessSettings processSettings)
        {
            var installedPackages = GetInstalledPlugins();

            if (toolSettings.Extensions.Count > 0 || installedPackages.Count > 0)
            {
                toolSettings = toolSettings.SetToolPath(
                    Path.Combine(
                        GetShadowDirectory(toolSettings, installedPackages),
                        GetPackageExecutable()));
            }

            return(ProcessTasks.StartProcess(toolSettings, processSettings));
        }
Ejemplo n.º 15
0
 public static void Run(
     string description, AbsolutePath workingDirectory, string tool, string?arguments = null,
     bool ignoreExitCode = false)
 {
     Logger.Info(description);
     using var proc = ProcessTasks.StartProcess(tool, arguments, workingDirectory);
     if (ignoreExitCode)
     {
         proc.AssertWaitForExit();
     }
     else
     {
         proc.AssertZeroExitCode();
     }
 }
        public static void SavePasswordToCredentialStore(string name, string password)
        {
            switch (EnvironmentInfo.Platform)
            {
            case PlatformFamily.OSX:
                ProcessTasks.StartProcess(
                    Security,
                    $"add-generic-password -T \"\" -a {EnvironmentInfo.Variables["LOGNAME"]} -s {name.DoubleQuoteIfNeeded()} -w {password}",
                    logInvocation: false,
                    logOutput: false).AssertZeroExitCode();
                break;

            default:
                throw new NotSupportedException(EnvironmentInfo.Platform.ToString());
            }
        }
Ejemplo n.º 17
0
        public static GitVersion GitVersion(Configure <GitVersionSettings> configurator = null)
        {
            var toolSettings    = configurator.InvokeSafe(new GitVersionSettings());
            var processSettings = new ProcessSettings().EnableRedirectOutput();

            var process = ProcessTasks.StartProcess(toolSettings, processSettings);

            process.AssertWaitForExit();
            if (process.ExitCode != 0)
            {
                ProcessTasks.StartProcess(toolSettings, processSettings.DisableRedirectOutput()).AssertZeroExitCode();
            }

            var output = process.Output.EnsureOnlyStd().Select(x => x.Text);

            return(JsonConvert.DeserializeObject <GitVersion>(string.Join("\r\n", output)));
        }
Ejemplo n.º 18
0
        private static IDictionary <string, string> GetCommonProperties(NukeBuild build = null)
        {
            var process = ControlFlow.SuppressErrors(
                () => ProcessTasks.StartProcess(DotNetTasks.DotNetPath, "--version", logInvocation: false, logOutput: false).AssertWaitForExit(),
                logWarning: false);

            return(new Dictionary <string, string>
            {
                ["os_platform"] = EnvironmentInfo.Platform.ToString(),
                ["os_architecture"] = RuntimeInformation.OSArchitecture.ToString(),
                ["version_dotnet_sdk"] = process?.ExitCode == 0 ? process.Output.First().Text : null,
                ["version_nuke_common"] = build != null ? typeof(NukeBuild).Assembly.GetVersionText() : null,
                ["version_nuke_global_tool"] = build != null
                           ? EnvironmentInfo.Variables.GetValueOrDefault(Constants.GlobalToolVersionEnvironmentKey)
                           : Assembly.GetEntryAssembly().GetVersionText()
            });
        }
Ejemplo n.º 19
0
        private static bool GitChanged(string nuspecPath)
        {
            var result = ProcessTasks.StartProcess("git", $"status {nuspecPath}").AssertWaitForExit();

            var filename = Path.GetFileName(nuspecPath);

            foreach (var line in result.Output)
            {
                if (line.Text.Contains(filename))
                {
                    Logger.Info("nuspec changed: {0}", line.Text);
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Moves a project of a solution:  Moves it's folder location to new location and then updates the solution.
        /// </summary>
        /// <param name="project">VisualStudioProject object representing the project to move.</param>
        /// <returns></returns>
        private bool MoveProjectStepA(VisualStudioProject project)
        {
            // Move project to new location
            if (project.OriginalPath.ToString() != project.NewPath.ToString())
            {
                Directory.Move(project.OriginalPath, project.NewPath);
            }

            // Remove from Solution
            string   removeParam = Path.Combine(project.OriginalPath, project.Namecsproj);
            IProcess sln         = ProcessTasks.StartProcess(DotNetPath, "sln " + CurrentSolutionPath + " remove " + removeParam, logOutput: true);

            sln.AssertWaitForExit();
            ControlFlow.Assert(sln.ExitCode == 0, "Failed to remove Project: " + project.Name + " from solution so we could move it.");

            return(true);
        }
Ejemplo n.º 21
0
        public static string GetPathExecutable(string pathExecutable)
        {
            // TODO UB: move to Core and call ProcessManager.Instance ? would require moving NuGetPackageResolver too and reference NuGet packages
            var locateExecutable = EnvironmentInfo.IsWin
                ? @"C:\Windows\System32\where.exe"
                : "/usr/bin/which";
            var locateProcess = ProcessTasks.StartProcess(
                locateExecutable,
                pathExecutable,
                redirectOutput: true);

            locateProcess.AssertWaitForExit();

            return(locateProcess.Output
                   .Select(x => x.Text)
                   .FirstOrDefault(File.Exists)
                   .NotNull($"Could not find '{pathExecutable}' via '{locateExecutable}'."));
        }
        public static string TryGetPasswordFromCredentialStore(string name)
        {
            switch (EnvironmentInfo.Platform)
            {
            case PlatformFamily.OSX:
                var process = ProcessTasks.StartProcess(
                    Security,
                    $"find-generic-password -w -a {EnvironmentInfo.Variables["LOGNAME"]} -s {name.DoubleQuoteIfNeeded()}",
                    logInvocation: false,
                    logOutput: false);
                process.WaitForExit();
                return(process.ExitCode == 0
                        ? process.Output.Single().Text
                        : null);

            default:
                return(null);
            }
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Run the typewriter publishing steps
        /// </summary>
        /// <returns></returns>
        protected override StageCompletionStatusEnum ExecuteProcess()
        {
            string command = "npm";
            string npmArgs = "run publishTW";

            CompletionStatus = StageCompletionStatusEnum.InProcess;

            foreach (SlugCIProject project in CISession.Projects)
            {
                AOT_Normal("Project: " + project.Name, Color.Magenta);
                AOT_Normal("  --> HasTypeWriterScripts:  " + project.HasTypeWriterScripts, Color.Magenta);

                if (!project.HasTypeWriterScripts)
                {
                    continue;
                }


                AbsolutePath scriptsFolder = project.VSProject.Directory / "_scripts";
                IProcess     process       = ProcessTasks.StartProcess(command, npmArgs, scriptsFolder, customLogger: NPMLogger);
                process.AssertWaitForExit();

                StageOutput.AddRange(process.Output);

                if (process.ExitCode != 0)
                {
                    SetInprocessStageStatus(StageCompletionStatusEnum.Failure);
                }
                else
                {
                    SetInprocessStageStatus(StageCompletionStatusEnum.Success);
                }
            }

            if (CompletionStatus == StageCompletionStatusEnum.InProcess)
            {
                CompletionStatus = StageCompletionStatusEnum.Success;
            }

            return(CompletionStatus);
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Run the Angular Build
        /// </summary>
        /// <returns></returns>
        protected override StageCompletionStatusEnum ExecuteProcess()
        {
            string command = "ng";
            string ngArgs  = "build";

            if (CISession.SkipAngularBuild)
            {
                return(StageCompletionStatusEnum.Skipped);
            }

            CompletionStatus = StageCompletionStatusEnum.InProcess;

            foreach (AngularProject project in CISession.SlugCIConfigObj.AngularProjects)
            {
                AddOutputText("Project: " + project.Name, OutputType.Std);

                AbsolutePath angularProjectPath = CISession.AngularDirectory / project.Name;
                IProcess     process            = ProcessTasks.StartProcess(command, ngArgs, angularProjectPath, customLogger: AngularLogger);
                process.AssertWaitForExit();

                StageOutput.AddRange(process.Output);

                if (process.ExitCode != 0)
                {
                    SetInprocessStageStatus(StageCompletionStatusEnum.Failure);
                    project.Results.CompileSuccess = false;
                }
                else
                {
                    SetInprocessStageStatus(StageCompletionStatusEnum.Success);
                    project.Results.CompileSuccess = true;
                }
            }

            if (CompletionStatus == StageCompletionStatusEnum.InProcess)
            {
                CompletionStatus = StageCompletionStatusEnum.Success;
            }

            return(CompletionStatus);
        }
Ejemplo n.º 25
0
        private static string PackPackage(string nuspecPath)
        {
            var proc = ProcessTasks.StartProcess("choco", $"pack {nuspecPath}").AssertWaitForExit();

            // Chocolatey v0.10.11
            // Attempting to build package from 'ncrunch-console.nuspec'.
            // Successfully created package 'D:\Privat\hbre-chocolatey\ncrunch-console\ncrunch-console.3.23.10.nupkg'

            var regEx = new Regex("Successfully created package '(.*)'");

            foreach (var line in proc.Output)
            {
                var match = regEx.Match(line.Text);
                if (match.Success)
                {
                    Logger.Trace("Text: {0}, Result{1}", line.Text, match.Groups[1].Value);
                    return(match.Groups[1].Value);
                }
            }
            return(null);
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Executes the Git Command, returning ONLY true or false to indicate success or failure
        /// </summary>
        /// <param name="cmdArguments"></param>
        /// <returns></returns>
        private bool ExecuteGit_NoOutput(string cmdArguments)
        {
            string command = "git";

            // Log it
            Output output = new Output();

            output.Text = GIT_COMMAND_MARKER + command + " " + cmdArguments;
            GitCommandOutputHistory.Add(output);

            IProcess process = ProcessTasks.StartProcess(command, cmdArguments, RootDirectory, logOutput: false);

            process.AssertWaitForExit();

            // Copy output to history.
            GitCommandOutputHistory.AddRange(process.Output);

            if (process.ExitCode != 0)
            {
                return(false);
            }
            return(true);
        }
Ejemplo n.º 27
0
        public void OnAfterLogo(
            NukeBuild build,
            IReadOnlyCollection <ExecutableTarget> executableTargets,
            IReadOnlyCollection <ExecutableTarget> executionPlan)
        {
            if (!AutoGenerate || NukeBuild.IsServerBuild)
            {
                return;
            }

            GeneratedFiles.ForEach(EnsureExistingParentDirectory);

            // TODO: necessary?
            Logger.LogLevel = LogLevel.Trace;
            var previousHashes = GeneratedFiles
                                 .Where(File.Exists)
                                 .ToDictionary(x => x, GetFileHash);

            var assembly = Assembly.GetEntryAssembly().NotNull("assembly != null");

            ProcessTasks.StartProcess(
                assembly.Location,
                $"--{ConfigurationParameterName} --host {HostType}",
                logInvocation: false,
                logOutput: true)
            .AssertZeroExitCode();

            var changedFiles = GeneratedFiles
                               .Where(x => GetFileHash(x) != previousHashes.GetValueOrDefault(x))
                               .Select(x => NukeBuild.RootDirectory.GetRelativePathTo(x)).ToList();

            if (changedFiles.Count > 0)
            {
                Logger.Warn($"{HostType} configuration files have changed.");
                changedFiles.ForEach(x => Logger.Trace($"Updated {x}"));
            }
        }
Ejemplo n.º 28
0
    void MargeFn(ProjectDefinition p)
    {
        var doNotMarge = new[]
        {
            "build.dll", "libcef.dll", "chrome_elf.dll", "d3dcompiler_47.dll",
            "libEGL.dll", "libGLESv2.dll", "CefSharp.dll", "CefSharp.Core.dll",
            "CefSharp.BrowserSubprocess.Core.dll"
        };
        var exclude = string.Join(' ', doNotMarge.Select(x => $"--exclude={x}"));

        var buildOut = TmpBuild / CommonDir.Build / p.Dir;
        var margeOut = TmpBuild / CommonDir.Merge / p.Dir;

        EnsureExistingDirectory(margeOut);
        CopyDirectoryRecursively(buildOut, margeOut, DirectoryExistsPolicy.Merge);

        using (var process = ProcessTasks.StartProcess(
                   LibzPath,
                   $"inject-dll --assembly {p.Exe} --include *.dll {exclude} --move",
                   margeOut))
        {
            process.AssertWaitForExit();
        }
    }
Ejemplo n.º 29
0
 /// <summary>
 ///   <p>VSWhere is designed to be a redistributable, single-file executable that can be used in build or deployment scripts to find where Visual Studio - or other products in the Visual Studio family - is located.</p>
 ///   <p>For more details, visit the <a href="https://github.com/Microsoft/vswhere">official website</a>.</p>
 /// </summary>
 public static IReadOnlyCollection <Output> VSWhere(string arguments, string workingDirectory = null, IReadOnlyDictionary <string, string> environmentVariables = null, int?timeout = null, bool?logOutput = null, bool?logInvocation = null, bool?logTimestamp = null, string logFile = null, Func <string, string> outputFilter = null)
 {
     using var process = ProcessTasks.StartProcess(VSWherePath, arguments, workingDirectory, environmentVariables, timeout, logOutput, logInvocation, logTimestamp, logFile, VSWhereLogger, outputFilter);
     process.AssertZeroExitCode();
     return(process.Output);
 }
Ejemplo n.º 30
0
 void DocFx(string command = "")
 {
     Ex(ProcessTasks.StartProcess(DocFxTool[0], DocFxTool.Length > 1 ? (string)(RootDirectory / DocFxTool[1]) + " " + command : command, DocFxDirectory));
 }