public Task ExecuteAsync(CommandLineArgs commandLineArgs) { var sw = new Stopwatch(); sw.Start(); var workingDirectory = commandLineArgs.Options.GetOrNull( Options.WorkingDirectory.Short, Options.WorkingDirectory.Long ); var dotnetBuildArguments = commandLineArgs.Options.GetOrNull( Options.DotnetBuildArguments.Short, Options.DotnetBuildArguments.Long ); var buildName = commandLineArgs.Options.GetOrNull( Options.BuildName.Short, Options.BuildName.Long ); var forceBuild = commandLineArgs.Options.ContainsKey(Options.ForceBuild.Short) || commandLineArgs.Options.ContainsKey(Options.ForceBuild.Long); var buildConfig = DotNetProjectBuildConfigReader.Read(workingDirectory ?? Directory.GetCurrentDirectory()); buildConfig.BuildName = buildName; buildConfig.ForceBuild = forceBuild; Console.WriteLine("Finding changed projects..."); var changedProjectFiles = ChangedProjectFinder.Find(buildConfig); var buildSucceededProjects = DotNetProjectBuilder.Build( changedProjectFiles, dotnetBuildArguments ?? "" ); var buildStatus = BuildStatusGenerator.Generate( buildConfig, changedProjectFiles, buildSucceededProjects ); RepositoryBuildStatusStore.Set(buildName, buildConfig.GitRepository, buildStatus); sw.Stop(); Console.WriteLine("Build operation is completed in " + sw.ElapsedMilliseconds + " (ms)"); return(Task.CompletedTask); }
public void Build() { var buildArtifacts = new[] { new FileDto { Name = "app.exe" } }; fileSystem.Setup(x => x.CleanFolder(args.BuildOutputFolder)); userPreferences.Setup(x => x.MsBuildPath).Returns(@"c:\build.exe"); runPowerShell.Setup(x => x.Invoke(DotNetProjectBuilder.MsBuildCommand.FormatWith(@"c:\build.exe", args.ProjectFile, args.BuildOutputFolder))); fileSystem.Setup(x => x.FindAllBinaries(args.BuildOutputFolder)).Returns(buildArtifacts); var result = builder.Build(args); result.Should().NotBeNull(); result.Artifacts.Should().Contain(buildArtifacts); }