Exemple #1
0
        private async Task PublishPackage(string packageId, string packageDefinitionFilename, string assemblyVersion, CancellationToken token)
        {
            var versionList = await nugetCore.GetAllPackageVersions(packageId, token);

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

            if (!VersionTools.HasUpdates(packageVersion, assemblyVersion))
            {
                Context.Output.WriteLine($"Package '{packageId}' is up-to-date. Version {packageVersion}", ConsoleColor.DarkCyan);
                return;
            }

            await nugetCmd.RunAsync(new NuGetPackArguments {
                Filename        = packageDefinitionFilename,
                Version         = assemblyVersion,
                OutputDirectory = nugetPackageDir,
                Properties      =
                {
                    ["Configuration"]    = "Release",
                    ["Platform"]         = "AnyCPU",
                    ["frameworkVersion"] = frameworkVersion,
                },
            }, token);

            var packageFilename = Directory
                                  .GetFiles(nugetPackageDir, $"{packageId}.*.nupkg")
                                  .FirstOrDefault();

            if (string.IsNullOrEmpty(packageFilename))
            {
                throw new ApplicationException($"No package found matching package ID '{packageId}'!");
            }

            await nugetCore.PushAsync(packageFilename, token);
        }
Exemple #2
0
        public async Task RunAsync(CancellationToken token)
        {
            nugetCore = new NuGetCore(Context)
            {
                ApiKey = Context.ServerVariables["global"]["nuget/apiKey"],
            };
            nugetCore.Initialize();

            var packageDir = Path.Combine(Context.BinDirectory, "PublishPackage");

            var packageFilename = Directory
                                  .GetFiles(packageDir, "jenkinsnet.*.nupkg")
                                  .FirstOrDefault();

            if (string.IsNullOrEmpty(packageFilename))
            {
                throw new ApplicationException("No package found matching package ID 'jenkinsnet'!");
            }

            await nugetCore.PushAsync(packageFilename, token);
        }