public override void ExecuteCommand() { // First argument should be the package string packagePath = Arguments[0]; // Don't push symbols by default string source = ResolveSource(packagePath); var apiKey = GetApiKey(source); if (String.IsNullOrEmpty(apiKey)) { throw new CommandLineException(NuGetResources.NoApiKeyFound, CommandLineUtility.GetSourceDisplayName(source)); } var timeout = TimeSpan.FromSeconds(Math.Abs(Timeout)); if (timeout.Seconds <= 0) { timeout = TimeSpan.FromMinutes(5); // Default to 5 minutes } PushPackage(packagePath, source, apiKey, timeout); if (source.Equals(NuGetConstants.DefaultGalleryServerUrl, StringComparison.OrdinalIgnoreCase)) { PushSymbols(packagePath, timeout); } }
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]; //If the user passed a source use it for the gallery location string source = SourceProvider.ResolveAndValidateSource(Source) ?? NuGetConstants.DefaultGalleryServerUrl; var gallery = new PackageServer(source, CommandLineConstants.UserAgent); //If the user did not pass an API Key look in the config file string apiKey = GetApiKey(source); string sourceDisplayName = CommandLineUtility.GetSourceDisplayName(source); if (NoPrompt || Console.Confirm(String.Format(CultureInfo.CurrentCulture, NuGetResources.DeleteCommandConfirm, packageId, packageVersion, sourceDisplayName))) { Console.WriteLine(NuGetResources.DeleteCommandDeletingPackage, packageId, packageVersion, sourceDisplayName); gallery.DeletePackage(apiKey, packageId, packageVersion); Console.WriteLine(NuGetResources.DeleteCommandDeletedPackage, packageId, packageVersion); } else { Console.WriteLine(NuGetResources.DeleteCommandCanceled); } }
private void PushPackageCore(string source, string apiKey, PackageServer packageServer, string packageToPush, TimeSpan timeout) { // Push the package to the server var package = new ZipPackage(packageToPush); string sourceName = CommandLineUtility.GetSourceDisplayName(source); Console.WriteLine(NuGetResources.PushCommandPushingPackage, package.GetFullName(), sourceName); packageServer.PushPackage(apiKey, package.GetStream, Convert.ToInt32(timeout.TotalMilliseconds)); Console.WriteLine(NuGetResources.PushCommandPackagePushed); }
public override void ExecuteCommand() { if (SourceProvider == null) { throw new InvalidOperationException(LocalizedResourceManager.GetString("Error_SourceProviderIsNull")); } if (Settings == null) { throw new InvalidOperationException(LocalizedResourceManager.GetString("Error_SettingsIsNull")); } //Frist argument should be the ApiKey string apiKey = Arguments[0]; bool setSymbolServerKey = false; //If the user passed a source use it for the gallery location string source; if (String.IsNullOrEmpty(Source)) { source = NuGetConstants.DefaultGalleryServerUrl; // If no source was specified, set the default symbol server key to be the same setSymbolServerKey = true; } else { source = SourceProvider.ResolveAndValidateSource(Source); } Settings.SetEncryptedValue(CommandLineUtility.ApiKeysSectionName, source, apiKey); string sourceName = CommandLineUtility.GetSourceDisplayName(source); // Setup the symbol server key if (setSymbolServerKey) { Settings.SetEncryptedValue(CommandLineUtility.ApiKeysSectionName, NuGetConstants.DefaultSymbolServerUrl, apiKey); Console.WriteLine(LocalizedResourceManager.GetString("SetApiKeyCommandDefaultApiKeysSaved"), apiKey, sourceName, CommandLineUtility.GetSourceDisplayName(NuGetConstants.DefaultSymbolServerUrl)); } else { Console.WriteLine(LocalizedResourceManager.GetString("SetApiKeyCommandApiKeySaved"), apiKey, sourceName); } }
private void PushPackageCore(string source, string apiKey, PackageServer packageServer, string packageToPush, TimeSpan timeout) { // Push the package to the server var package = new OptimizedZipPackage(packageToPush); string sourceName = CommandLineUtility.GetSourceDisplayName(source); Console.WriteLine(LocalizedResourceManager.GetString("PushCommandPushingPackage"), package.GetFullName(), sourceName); packageServer.PushPackage( apiKey, package, new FileInfo(packageToPush).Length, Convert.ToInt32(timeout.TotalMilliseconds)); Console.WriteLine(LocalizedResourceManager.GetString("PushCommandPackagePushed")); }
public override void ExecuteCommand() { if (NoPrompt) { Console.WriteWarning(NuGetResources.Warning_NoPromptDeprecated); NonInteractive = true; } //First argument should be the package ID string packageId = Arguments[0]; //Second argument should be the package Version string packageVersion = Arguments[1]; //If the user passed a source use it for the gallery location string source = SourceProvider.ResolveAndValidateSource(Source) ?? NuGetConstants.DefaultGalleryServerUrl; var gallery = new PackageServer(source, CommandLineConstants.UserAgent); gallery.SendingRequest += (sender, e) => { if (Console.Verbosity == NuGet.Verbosity.Detailed) { Console.WriteLine(ConsoleColor.Green, "{0} {1}", e.Request.Method, e.Request.RequestUri); } }; //If the user did not pass an API Key look in the config file string apiKey = GetApiKey(source); string sourceDisplayName = CommandLineUtility.GetSourceDisplayName(source); if (String.IsNullOrEmpty(apiKey)) { Console.WriteWarning(NuGetResources.NoApiKeyFound, sourceDisplayName); } if (NonInteractive || Console.Confirm(String.Format(CultureInfo.CurrentCulture, NuGetResources.DeleteCommandConfirm, packageId, packageVersion, sourceDisplayName))) { Console.WriteLine(NuGetResources.DeleteCommandDeletingPackage, packageId, packageVersion, sourceDisplayName); gallery.DeletePackage(apiKey, packageId, packageVersion); Console.WriteLine(NuGetResources.DeleteCommandDeletedPackage, packageId, packageVersion); } else { Console.WriteLine(NuGetResources.DeleteCommandCanceled); } }
public override void ExecuteCommand() { //Frist argument should be the ApiKey string apiKey = Arguments[0]; bool setSymbolServerKey = false; //If the user passed a source use it for the gallery location string galleryServerUrl; if (String.IsNullOrEmpty(Source)) { galleryServerUrl = GalleryServer.DefaultGalleryServerUrl; // If no source was specified, set the default symbol server key to be the same setSymbolServerKey = true; } else { CommandLineUtility.ValidateSource(Source); galleryServerUrl = Source; } var settings = Settings.UserSettings; settings.SetEncryptedValue(CommandLineUtility.ApiKeysSectionName, galleryServerUrl, apiKey); // Setup the symbol server key if (setSymbolServerKey) { settings.SetEncryptedValue(CommandLineUtility.ApiKeysSectionName, GalleryServer.DefaultSymbolServerUrl, apiKey); Console.WriteLine(NuGetResources.SetApiKeyCommandDefaultApiKeysSaved, apiKey, CommandLineUtility.GetSourceDisplayName(galleryServerUrl), CommandLineUtility.GetSourceDisplayName(GalleryServer.DefaultSymbolServerUrl)); } else { Console.WriteLine(NuGetResources.SetApiKeyCommandApiKeySaved, apiKey, CommandLineUtility.GetSourceDisplayName(galleryServerUrl)); } }
public override void ExecuteCommand() { // First argument should be the package string packagePath = Arguments[0]; // Don't push symbols by default string source = ResolveSource(packagePath, ConfigurationDefaults.Instance.DefaultPushSource); var apiKey = GetApiKey(source); if (String.IsNullOrEmpty(apiKey) && !IsFileSource(source)) { Console.WriteWarning(LocalizedResourceManager.GetString("NoApiKeyFound"), CommandLineUtility.GetSourceDisplayName(source)); } var timeout = TimeSpan.FromSeconds(Math.Abs(Timeout)); if (timeout.Seconds <= 0) { timeout = TimeSpan.FromMinutes(5); // Default to 5 minutes } PushPackage(packagePath, source, apiKey, timeout); if (source.Equals(NuGetConstants.DefaultGalleryServerUrl, StringComparison.OrdinalIgnoreCase)) { PushSymbols(packagePath, timeout); } }
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); } }
public void AddPackage(IPackage package) { _logger.Log(MessageLevel.Info, NuGetResources.MirrorCommandPushingPackage, package.GetFullName(), CommandLineUtility.GetSourceDisplayName(_destination.Source)); _destination.PushPackage(_apiKey, package, (int)_timeout.TotalMilliseconds); _logger.Log(MessageLevel.Info, NuGetResources.MirrorCommandPackagePushed); }
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); }