Exemple #1
0
        private void PushPackage(string packagePath, string source, string apiKey = null)
        {
            var gallery = new GalleryServer(source);

            // Use the specified api key or fall back to default behavior
            apiKey = apiKey ?? GetApiKey(source);

            // Push the package to the server
            var package = new ZipPackage(packagePath);

            Console.WriteLine(NuGetResources.PushCommandPushingPackage, package.GetFullName(), CommandLineUtility.GetSourceDisplayName(source));

            using (Stream stream = package.GetStream()) {
                gallery.CreatePackage(apiKey, stream);
            }

            // Publish the package on the server
            if (!CreateOnly)
            {
                var cmd = new PublishCommand();
                cmd.Console   = Console;
                cmd.Source    = source;
                cmd.Arguments = new List <string> {
                    package.Id, package.Version.ToString(), apiKey
                };
                cmd.Execute();
            }
            else
            {
                Console.WriteLine(NuGetResources.PushCommandPackageCreated, source);
            }
        }
Exemple #2
0
        public override void ExecuteCommand()
        {
            //Frist argument should be the package ID
            string packageId = Arguments[0];
            //Second argument should be the package Version
            string packageVersion = Arguments[1];
            //Third argument if present should be the API Key
            string userSetApiKey = null;

            if (Arguments.Count > 2)
            {
                userSetApiKey = Arguments[2];
            }

            //If the user passed a source use it for the gallery location
            string galleryServerUrl = String.IsNullOrEmpty(Source) ? GalleryServer.DefaultGalleryServerUrl : Source;
            var    gallery          = new GalleryServer(galleryServerUrl);

            //If the user did not pass an API Key look in the config file
            string apiKey = String.IsNullOrEmpty(userSetApiKey) ? CommandLineUtility.GetApiKey(Settings.UserSettings, galleryServerUrl) : userSetApiKey;

            Console.WriteLine(NuGetResources.PublishCommandPublishingPackage, packageId, packageVersion, CommandLineUtility.GetSourceDisplayName(Source));
            gallery.PublishPackage(apiKey, packageId, packageVersion);
            Console.WriteLine(NuGetResources.PublishCommandPackagePublished);
        }
Exemple #3
0
        public override void ExecuteCommand()
        {
            //First argument should be the package ID
            string packageId = Arguments[0];
            //Second argument should be the package Version
            string packageVersion = Arguments[1];
            //Third argument, if present, should be the API Key
            string userSetApiKey = null;

            if (Arguments.Count > 2)
            {
                userSetApiKey = Arguments[2];
            }

            //If the user passed a source use it for the gallery location
            string galleryServerUrl = String.IsNullOrEmpty(Source) ? GalleryServer.DefaultGalleryServerUrl : Source;
            var    gallery          = new GalleryServer(galleryServerUrl);

            //If the user did not pass an API Key look in the config file
            string apiKey = String.IsNullOrEmpty(userSetApiKey) ? CommandLineUtility.GetApiKey(Settings.UserSettings, galleryServerUrl) : userSetApiKey;


            if (NoPrompt || Console.Confirm(String.Format(CultureInfo.CurrentCulture, NuGetResources.DeleteCommandConfirm, packageId, packageVersion)))
            {
                Console.WriteLine(NuGetResources.DeleteCommandDeletingPackage, packageId, packageVersion);
                gallery.DeletePackage(apiKey, packageId, packageVersion);
                Console.WriteLine(NuGetResources.DeleteCommandDeletedPackage, packageId, packageVersion);
            }
            else
            {
                Console.WriteLine(NuGetResources.DeleteCommandCanceled);
            }
        }
Exemple #4
0
        public override void ExecuteCommand()
        {
            //Frist argument should be the package ID
            string packageId = Arguments[0];
            //Second argument should be the package Version
            string packageVersion = Arguments[1];
            //Third argument if present should be the API Key
            string userSetApiKey = null;
            if (Arguments.Count > 2) {
                userSetApiKey = Arguments[2];
            }

            //If the user passed a source use it for the gallery location
            string galleryServerUrl = String.IsNullOrEmpty(Source) ? GalleryServer.DefaultGalleryServerUrl : Source;
            var gallery = new GalleryServer(galleryServerUrl);

            //If the user did not pass an API Key look in the config file
            string apiKey = String.IsNullOrEmpty(userSetApiKey) ? CommandLineUtility.GetApiKey(Settings.UserSettings, galleryServerUrl) : userSetApiKey;

            Console.WriteLine(NuGetResources.PublishCommandPublishingPackage, packageId, packageVersion, CommandLineUtility.GetSourceDisplayName(Source));
            gallery.PublishPackage(apiKey, packageId, packageVersion);
            Console.WriteLine(NuGetResources.PublishCommandPackagePublished);
        }
Exemple #5
0
        private void PushPackage(string packagePath, string source, string apiKey) {
            var gallery = new GalleryServer(source);

            // Push the package to the server
            var package = new ZipPackage(packagePath);

            bool complete = false;
            gallery.ProgressAvailable += (sender, e) => {
                                             Console.Write("\r" + "Pushing: {0}", e.PercentComplete);

                                             if (e.PercentComplete == 100) {
                                                 Console.WriteLine();
                                                 complete = true;
                                             }
                                         };

            Console.WriteLine("Pushing {0} to {1}", package.GetFullName(), SourceProvider.GetDisplayName(source));

            try {
                using (Stream stream = package.GetStream()) {
                    gallery.CreatePackage(apiKey, stream);
                }
            }
            catch {
                if (!complete) {
                    Console.WriteLine();
                }
                throw;
            }

            // Publish the package on the server

            var cmd = new PublishCommand(SourceProvider);
            cmd.Console = Console;
            cmd.Source = source;
            cmd.Arguments = new List<string> {
                                                 package.Id,
                                                 package.Version.ToString(),
                                                 apiKey
                                             };
            cmd.Execute();
        }
Exemple #6
0
        private void PushPackage(string packagePath, string source, string apiKey = null)
        {
            var gallery = new GalleryServer(source);

            // Use the specified api key or fall back to default behavior
            apiKey = apiKey ?? GetApiKey(source);

            // Push the package to the server
            var package = new ZipPackage(packagePath);

            Console.WriteLine(NuGetResources.PushCommandPushingPackage, package.GetFullName(), CommandLineUtility.GetSourceDisplayName(source));

            using (Stream stream = package.GetStream()) {
                gallery.CreatePackage(apiKey, stream);
            }

            // Publish the package on the server
            if (!CreateOnly) {
                var cmd = new PublishCommand();
                cmd.Console = Console;
                cmd.Source = source;
                cmd.Arguments = new List<string> { package.Id, package.Version.ToString(), apiKey };
                cmd.Execute();
            }
            else {
                Console.WriteLine(NuGetResources.PushCommandPackageCreated, source);
            }
        }