Example #1
0
        public async Task BuildAsync()
        {
            if (string.IsNullOrEmpty(Filename))
            {
                throw new ArgumentNullException(nameof(Filename));
            }

            var args = new List <string> {
                Filename,
                "/t:Rebuild",
                "/v:m",
            };

            if (!string.IsNullOrEmpty(Configuration))
            {
                args.Add($"/p:Configuration=\"{Configuration}\"");
            }

            if (!string.IsNullOrEmpty(Platform))
            {
                args.Add($"/p:Platform=\"{Platform}\"");
            }

            if (Parallel)
            {
                args.Add("/m");
            }

            await context.RunCommandLineAsync(Exe, args.ToArray());
        }
Example #2
0
        public async Task PublishAsync(CancellationToken token)
        {
            context.Output
            .Append("Updating Package ", ConsoleColor.DarkCyan)
            .Append(PackageId, ConsoleColor.Cyan)
            .AppendLine("...", ConsoleColor.DarkCyan);

            var versionList = await client.GetAllPackageVersions(PackageId, token);

            var packageVersion = versionList.Any() ? versionList.Max() : null;

            if (!HasUpdates(packageVersion, AssemblyVersion))
            {
                context.Output
                .Append($"Package '{PackageId}' is up-to-date. Version ", ConsoleColor.DarkBlue)
                .AppendLine(packageVersion, ConsoleColor.Blue);

                return;
            }

            var packageFile = Path.Combine(PackageDirectory, $"{PackageId}.*.nupkg");

            await context.RunCommandLineAsync(NugetExe, "pack",
                                              $"\"{ProjectFile}\"",
                                              $"-Prop \"Configuration={Configuration};Platform={Platform}\"",
                                              $"-OutputDirectory \"{PackageDirectory}\"");

            await context.RunCommandLineAsync(NugetExe, "push",
                                              $"\"{packageFile}\"",
                                              $"-Source \"{Source}\"",
                                              "-NonInteractive",
                                              $"-ApiKey \"{ApiKey}\"");

            context.Output
            .Append("Package ", ConsoleColor.DarkGreen)
            .Append(PackageId, ConsoleColor.Green)
            .AppendLine(" pushed successfully.", ConsoleColor.DarkGreen);
        }