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); } }
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(); }
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); } }