private static GitHubFlowVersionContext CreateContext(GitHubFlowArguments arguments)
        {
            var context = new GitHubFlowVersionContext
            {
                Arguments        = arguments,
                WorkingDirectory =
                    arguments.WorkingDirectory ??
                    Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)
            };
            var fallbackStrategy = new LocalBuild();
            var buildServers     = new IBuildServer[] { new TeamCity(context) };

            context.CurrentBuildServer = buildServers.FirstOrDefault(s => s.IsRunningInBuildAgent()) ?? fallbackStrategy;

            context.GitDirectory = GitDirFinder.TreeWalkForGitDir(context.WorkingDirectory);
            if (string.IsNullOrEmpty(context.GitDirectory))
            {
                if (context.CurrentBuildServer.IsRunningInBuildAgent()) //fail the build if we're on a TC build agent
                {
                    // This exception might have to change when more build servers are added
                    throw new Exception("Failed to find .git directory on agent. " +
                                        "Please make sure agent checkout mode is enabled for you VCS roots - " +
                                        "http://confluence.jetbrains.com/display/TCD8/VCS+Checkout+Mode");
                }

                throw new Exception("Failed to find .git directory.");
            }

            Console.WriteLine("Git directory found at {0}", context.GitDirectory);
            context.RepositoryRoot = Directory.GetParent(context.GitDirectory).FullName;

            return(context);
        }
示例#2
0
        public Optional <ProjectBuild> TryBuild(BuildProject args, Log logger)
        {
            try
            {
                var project = _simulatorBuilder.CreateSimulatorProject(args);

                var libraryBuilder = new LibraryBuilder(new Disk(logger), BuildTargets.Package)
                {
                    Express = true
                };
                var projectBuilder = new ProjectBuilder(logger, new LocalSimulatorTarget(), project.Options);

                if (project.IsVerboseBuild)
                {
                    logger.Level = Uno.Logging.LogLevel.Verbose;
                }

                if (project.BuildLibraries)
                {
                    libraryBuilder.Build();
                }

                var buildResult = projectBuilder.Build(project.Project);

                if (buildResult.ErrorCount != 0)
                {
                    return(Optional.None());
                }

                var b = new LocalBuild(buildResult, AbsoluteFilePath.Parse(args.ProjectPath));
                return(new ProjectBuild(b.Path.NativePath, b.SaveSimulatorMetadata(_fileSystem).NativePath, b.GetTypeInformation()));
            }
            catch (ThreadAbortException)
            {
            }
            catch (SourceException e)
            {
                logger.Error(e.Source, null, e.Message);
            }
            catch (Exception e)
            {
                logger.Error(e.Message);
            }
            return(Optional.None());
        }