Пример #1
0
        public static void PublishNuGets(this ICakeContext context, string readSource, string publishSource, string apiKey, PublishNuGetsSettings settings, params string[] nupkgFileGlobbingPatterns)
        {
            foreach (var pattern in nupkgFileGlobbingPatterns)
            {
                var files = context.GetFiles(pattern);
                if (files == null || !files.Any())
                {
                    continue;
                }

                foreach (var file in files)
                {
                    if (!settings.ForcePush &&
                        !string.IsNullOrEmpty(readSource) ? IsNuGetPublished(context, file, readSource) : IsNuGetPublished(context, file))
                    {
                        context.Information("Already published: {0}", file);
                        continue;
                    }

                    context.Information("Attempting to publish {0}", file);

                    int  attempts = 0;
                    bool success  = false;

                    while (attempts < settings.MaxAttempts)
                    {
                        attempts++;

                        try {
                            var ns = new NuGetPushSettings {
                                ApiKey = apiKey
                            };

                            if (!string.IsNullOrEmpty(publishSource))
                            {
                                ns.Source = publishSource;
                            }

                            context.NuGetPush(file, ns);
                            success = true;
                            break;
                        } catch {
                            context.Warning("Attempt #{0} of {1} failed...", attempts, settings.MaxAttempts);
                        }
                    }

                    if (!success)
                    {
                        var msg = "Maximum # of attempts ({0}) to publish exceeded";
                        context.Error(msg, settings.MaxAttempts);
                        throw new Exception(string.Format(msg, settings.MaxAttempts));
                    }

                    context.Information("Published Package successfully: {0}", file);
                }
            }
        }
Пример #2
0
        public static void PublishNuGets (this ICakeContext context, string readSource, string publishSource, string apiKey, PublishNuGetsSettings settings, params string[] nupkgFileGlobbingPatterns)
        {
            foreach (var pattern in nupkgFileGlobbingPatterns)
            {
                var files = context.GetFiles(pattern);
                if (files == null || !files.Any())
                    continue;

                foreach (var file in files)
                {
                    if (!settings.ForcePush 
                        && !string.IsNullOrEmpty (readSource) ? IsNuGetPublished (context, file, readSource) : IsNuGetPublished (context, file))
                    {
                        context.Information("Already published: {0}", file);
                        continue;
                    }

                    context.Information("Attempting to publish {0}", file);

                    int attempts = 0;
                    bool success = false;

                    while (attempts < settings.MaxAttempts)
                    {
                        attempts++;

                        try {
                            var ns = new NuGetPushSettings {
                                ApiKey = apiKey
                            };

                            if (!string.IsNullOrEmpty (publishSource))
                                ns.Source = publishSource;
                            
                            context.NuGetPush (file, ns);
                            success = true;
                            break;
                        } catch {
                            context.Warning("Attempt #{0} of {1} failed...", attempts, settings.MaxAttempts);
                        }
                    }

                    if (!success)
                    {
                        var msg = "Maximum # of attempts ({0}) to publish exceeded";
                        context.Error(msg, settings.MaxAttempts);
                        throw new Exception(string.Format (msg, settings.MaxAttempts));
                    }

                    context.Information("Published Package successfully: {0}", file);
                }
            }
        }
Пример #3
0
 public static void PublishNuGets(this ICakeContext context, string nugetSource, string apiKey, PublishNuGetsSettings settings, params string [] nupkgFileGlobbingPatterns)
 {
     PublishNuGets(context, nugetSource, nugetSource, apiKey, settings, nupkgFileGlobbingPatterns);
 }
Пример #4
0
 public static void PublishNuGets (this ICakeContext context, string nugetSource, string apiKey, PublishNuGetsSettings settings, params string [] nupkgFileGlobbingPatterns)
 {
     PublishNuGets (context, nugetSource, nugetSource, apiKey, settings, nupkgFileGlobbingPatterns);
 }