Exemplo n.º 1
0
        async Task CleanProjectAsync(string project_file, string project_platform, string project_configuration, ILog log, ILog mainLog)
        {
            // Don't require the desktop resource here, this shouldn't be that resource sensitive
            using (var xbuild = new Process()) {
                xbuild.StartInfo.FileName = msbuildPath;
                var args = new List <string> ();
                args.Add("--");
                args.Add("/verbosity:diagnostic");
                if (project_platform != null)
                {
                    args.Add($"/p:Platform={project_platform}");
                }
                if (project_configuration != null)
                {
                    args.Add($"/p:Configuration={project_configuration}");
                }
                args.Add(project_file);
                args.Add("/t:Clean");
                xbuild.StartInfo.Arguments = StringUtils.FormatArguments(args);
                EnviromentManager.SetEnvironmentVariables(xbuild);
                EventLogger.LogEvent(log, "Cleaning {0} ({1}) - {2}", TestName, Mode, project_file);
                var timeout = TimeSpan.FromMinutes(1);
                await ProcessManager.RunAsync(xbuild, log, timeout);

                log.WriteLine("Clean timed out after {0} seconds.", timeout.TotalSeconds);
                mainLog.WriteLine("Cleaned {0} ({1})", TestName, Mode);
            }
        }
Exemplo n.º 2
0
        public async Task <(TestExecutingResult ExecutionResult, (string HumanMessage, string IssueLink)? KnownFailure)> ExecuteAsync(string projectPlatform,
                                                                                                                                      string projectConfiguration,
                                                                                                                                      string projectFile,
                                                                                                                                      IAcquiredResource resource,
                                                                                                                                      bool dryRun,
                                                                                                                                      ILog buildLog,
                                                                                                                                      ILog mainLog)
        {
            BuildLog = buildLog;
            (TestExecutingResult ExecutionResult, (string HumanMessage, string IssueLink)? KnownFailure)result = (TestExecutingResult.NotStarted, ((string HumanMessage, string IssueLink)?)null);
            var restoreResult = await RestoreNugetsAsync(buildLog, resource);

            if ((restoreResult & TestExecutingResult.Failed) == TestExecutingResult.Failed)
            {
                BuildLog.WriteLine($"Failed to restore nugets: {restoreResult}");
                result.ExecutionResult = restoreResult;
                return(result);
            }

            using (var xbuild = new Process()) {
                xbuild.StartInfo.FileName         = msbuildPath();
                xbuild.StartInfo.Arguments        = StringUtils.FormatArguments(GetToolArguments(projectPlatform, projectConfiguration, projectFile, buildLog));
                xbuild.StartInfo.WorkingDirectory = Path.GetDirectoryName(projectFile);
                EnviromentManager.SetEnvironmentVariables(xbuild);
                xbuild.StartInfo.EnvironmentVariables ["MSBuildExtensionsPath"] = null;
                EventLogger.LogEvent(buildLog, "Building {0} ({1})", TestName, Mode);
                if (!dryRun)
                {
                    var timeout       = TimeSpan.FromMinutes(60);
                    var processResult = await ProcessManager.RunAsync(xbuild, buildLog, timeout);

                    if (processResult.TimedOut)
                    {
                        result.ExecutionResult = TestExecutingResult.TimedOut;
                        buildLog.WriteLine("Build timed out after {0} seconds.", timeout.TotalSeconds);
                    }
                    else if (processResult.Succeeded)
                    {
                        result.ExecutionResult = TestExecutingResult.Succeeded;
                    }
                    else
                    {
                        result.ExecutionResult = TestExecutingResult.Failed;
                        if (errorKnowledgeBase.IsKnownBuildIssue(buildLog, out result.KnownFailure))
                        {
                            buildLog.WriteLine($"Build has a known failure: '{result.KnownFailure}'");
                        }
                    }
                }
                mainLog.WriteLine("Built {0} ({1})", TestName, Mode);
            }
            return(result);
        }
Exemplo n.º 3
0
        async Task <TestExecutingResult> RestoreNugetsAsync(string projectPath, ILog log, bool useXIBuild = false)
        {
            using (var resource = await ResourceManager.NugetResource.AcquireExclusiveAsync()) {
                // we do not want to use xibuild on solutions, we will have some failures with Mac Full
                var isSolution = projectPath.EndsWith(".sln", StringComparison.Ordinal);
                if (!File.Exists(projectPath))
                {
                    throw new FileNotFoundException("Could not find the solution whose nugets to restore.", projectPath);
                }

                using (var nuget = new Process()) {
                    nuget.StartInfo.FileName = useXIBuild && !isSolution ? msbuildPath:
                                               "/Library/Frameworks/Mono.framework/Versions/Current/Commands/nuget";
                    var args = new List <string> ();
                    args.Add((useXIBuild && !isSolution ? "/" : "") + "restore");                      // diff param depending on the tool
                    args.Add(projectPath);
                    if (useXIBuild && !isSolution)
                    {
                        args.Add("/verbosity:detailed");
                    }
                    else
                    {
                        args.Add("-verbosity");
                        args.Add("detailed");
                    }
                    nuget.StartInfo.Arguments = StringUtils.FormatArguments(args);
                    EnviromentManager.SetEnvironmentVariables(nuget);
                    EventLogger.LogEvent(log, "Restoring nugets for {0} ({1}) on path {2}", TestName, Mode, projectPath);

                    var timeout = TimeSpan.FromMinutes(15);
                    var result  = await ProcessManager.RunAsync(nuget, log, timeout);

                    if (result.TimedOut)
                    {
                        log.WriteLine("Nuget restore timed out after {0} seconds.", timeout.TotalSeconds);
                        return(TestExecutingResult.TimedOut);
                    }
                    else if (!result.Succeeded)
                    {
                        return(TestExecutingResult.Failed);
                    }
                }

                EventLogger.LogEvent(log, "Restoring nugets completed for {0} ({1}) on path {2}", TestName, Mode, projectPath);
                return(TestExecutingResult.Succeeded);
            }
        }