예제 #1
0
        protected override Task <int> InnerRunAsync(BuildArgs args, ILogger log)
        {
            log.Info($"Starting {nameof(SolutionBuild)}");
            var dotnetAction = args.Publish ? "Publish" : "Build";

            foreach (var project in args.ReleaseProjects)
            {
                var actionBlock = $"{dotnetAction.ToLowerInvariant()} \"{project.FullName()}\" --configuration {args.Configuration} --verbosity quiet /p:Version={args.Version.SemVer20String}";

                if (args.Publish)
                {
                    actionBlock += $" --runtime {args.Runtime}";
                }
                else
                {
                    actionBlock += $" --no-incremental";
                }


                log.Info($"{dotnetAction}ing {project.NameWoExtension.Highlight()}");

                log.Info(actionBlock.Highlight());
                var exitCode = ExternalProcess.Run("dotnet", actionBlock, log.Debug, log.Error);
                if (exitCode != 0)
                {
                    throw new CliException($"{dotnetAction} failed for {project.NameWoExtension.Highlight()}. See logs for details", 400);
                }
            }

            return(Task.FromResult(0));
        }
예제 #2
0
        private void ZipIt(BuildArgs args, ILogger log)
        {
            var sevenZip = new SevenZipExe(log.Debug, log.Error, log.Verbose);

            args.ReleaseArtifactsDir.EnumerateDirectories().ForEachParallel(moduleDir =>
            {
                var runTimesDir = moduleDir.EnumerateDirectories("runtimes").SingleOrDefault();
                var modulePath  = args.ReleaseArtifactsDir.ToFile($"{moduleDir.Name}_{args.Version.SemVer20String}");

                log.Debug($"Archive name resolved to: {modulePath}");
                sevenZip.Create7zFromDirectory(moduleDir.FullName(), modulePath.FullName());
                if (runTimesDir == null)
                {
                    return;
                }

                var outputSize = new FileInfo($"{modulePath}.7z").Length;

                if (outputSize <= 0)
                {
                    throw new CliException($"{modulePath} not found. This should never happen. Has the file been deleted?");
                }

                if (outputSize < 10000000)//only create separate tool and runtimes packages when package is more than 10MB (secure file max size on Azure DevOps)
                {
                    return;
                }

                log.Debug($"{modulePath.Name} is larger than 10MB. Splitting runtimes and tool into separate packages");

                sevenZip.Create7zFromDirectory(runTimesDir.FullName(), $"{modulePath.FullName()}_Runtimes");
                runTimesDir.DeleteIfExists();
                sevenZip.Create7zFromDirectory(moduleDir.FullName(), $"{modulePath.FullName()}_Tool");
            });
        }
예제 #3
0
        protected override Task <int> InnerRunAsync(BuildArgs args, ILogger log)
        {
            log.Info($"Starting {nameof(SolutionPreBuild)}");

            InitDir(args.ReleaseArtifactsDir, log);

            //add csproj bin dirs
            var csprojBinDirs = args.SolutionDir.EnumerateDirectories("bin", SearchOption.AllDirectories).OrderByDescending(dir => dir.FullName());

            csprojBinDirs.ForEachParallel(binDir => InitDir(binDir, log));
            return(Task.FromResult(0));
        }
예제 #4
0
        public async Task <int> DispatchAsync(CliHost <BuildArgs> host, BuildArgs args)
        {
            var stepsToRun = (host.IsSet(RunOnlyFlag)
                ? host[RunOnlyFlag].Split('|', StringSplitOptions.RemoveEmptyEntries)
                : _steps.Select(step => step.Flag)).ToList();

            host.Log.Info($"Enabled steps: {stepsToRun.JoinString()}");

            foreach (var buildStep in _steps)
            {
                await TryDispatchAsync(buildStep, stepsToRun, host, args).ConfigureAwait(false);
            }

            return(0);
        }
예제 #5
0
        protected override Task <int> InnerRunAsync(BuildArgs args, ILogger log)
        {
            log.Info($"Starting {nameof(SolutionPostBuild)}");
            args.ReleaseProjects.ForEachParallel(proj =>
            {
                var artifactsSourceDir = GetArtifactsSourceDir(proj, args);
                var artifactsTargetDir = args.ReleaseArtifactsDir.Add(proj.NameWoExtension);

                CleanExcessiveCompileArtifacts(artifactsSourceDir, log);

                if (args.IsAuxiliary)
                {
                    RemoveReleaseAssemblies(artifactsSourceDir, proj.NameWoExtension, log);
                }

                if (args.DllsInBinFolderRoles.Any())
                {
                    log.Info($"Asserting Dlls In Bin Folder Roles ");
                    ProcessDllsInBinFolderRoles(artifactsSourceDir, args.DllsInBinFolderRoles, log);
                }

                log.Info($"Asserting Web Jobs");
                AssertWebJob(artifactsSourceDir, proj.NameWoExtension, log);

                log.Info($"Copying Release Artifacts");
                CopyReleaseArtifacts(artifactsSourceDir, artifactsTargetDir, log);
            });

            log.Info($"Scanning for Nuget Packages");
            args.ReleaseProjects.ForEachParallel(proj => CopyNugetPackages(proj, args.ReleaseArtifactsDir));

            if (args.ZipIt)
            {
                log.Info($"Zipping release artifacts");
                ZipIt(args, log);
            }

            return(Task.FromResult(0));
        }
예제 #6
0
        private DirPath GetArtifactsSourceDir(FilePath projectFile, BuildArgs args)
        {
            var sourceDir = projectFile.Directory().ToDir("bin");

            if (sourceDir.Add(args.Configuration).Exists())
            {
                sourceDir = sourceDir.Add(args.Configuration);
            }
            try
            {
                sourceDir = sourceDir.EnumerateDirectories().SingleOrDefault() ?? sourceDir;//look for target framework dir
            }
            catch (InvalidOperationException)
            {
                //ignore if there's more than a single file.
            }

            if (args.Publish)
            {
                sourceDir = sourceDir.Add(args.Runtime, nameof(args.Publish));
            }
            return(sourceDir);
        }
예제 #7
0
 protected abstract Task <int> InnerRunAsync(BuildArgs args, ILogger log);
예제 #8
0
 public virtual Task <int> RunAsync(BuildArgs args, ILogger log)
 {
     return(InnerRunAsync(args, log?.InContext(Flag)));
 }
예제 #9
0
        public async Task <int> TryDispatchAsync(BuildStep step, IEnumerable <string> stepsToRun, CliHost <BuildArgs> host, BuildArgs args)
        {
            if (!ShouldRun(step.Flag, stepsToRun))
            {
                return(0);
            }

            host.Log.Info(GetBuildStart(step.Flag, args.SolutionDir.Name));
            var exitCode = await step.RunAsync(args, host.Log).ConfigureAwait(false);

            if (exitCode != 0)
            {
                throw new CliException($"{step.Flag} FAILED. See log for details", exitCode);
            }

            return(exitCode);
        }