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); }
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); } }
private string GetApiKey(string source, bool throwIfNotFound = true) { string apiKey = null; // Second argument, if present, should be the API Key if (Arguments.Count > 1) { apiKey = Arguments[1]; } // If the user did not pass an API Key look in the config file if (String.IsNullOrEmpty(apiKey)) { apiKey = CommandLineUtility.GetApiKey(Settings.UserSettings, source, throwIfNotFound); } return(apiKey); }
internal string GetApiKey(string source) { string apiKey = null; if (!String.IsNullOrEmpty(ApiKey)) { return(ApiKey); } // Second argument, if present, should be the API Key if (Arguments.Count > 2) { apiKey = Arguments[2]; } // If the user did not pass an API Key look in the config file if (String.IsNullOrEmpty(apiKey)) { apiKey = CommandLineUtility.GetApiKey(Settings, source); } return(apiKey); }
private string GetApiKey(string source) { return(String.IsNullOrEmpty(ApiKey) ? CommandLineUtility.GetApiKey(Settings, source) : ApiKey); }