Exemple #1
0
        public async Task PushPackage()
        {
            ShowProgress = true;
            Status       = (PublishAsUnlisted == true) ? "Publishing and unlisting package..." : "Publishing package...";
            HasError     = false;
            CanPublish   = false;

            try
            {
                await GalleryServer.PushPackage(PublishKey, _packageFilePath, _package, PublishAsUnlisted ?? false, AppendV2ApiToUrl ?? false);

                OnCompleted();
            }
            catch (Exception exception)
            {
                OnError(exception);
            }
            finally
            {
                // add the publish url to the list
                _mruSourceManager.NotifyPackageSourceAdded(PublishUrl);

                // this is to make sure the combo box doesn't goes blank after publishing
                try
                {
                    _suppressReadingApiKey = true;
                    SelectedPublishItem    = PublishUrl;
                }
                finally
                {
                    _suppressReadingApiKey = false;
                }
            }
        }
Exemple #2
0
        public async Task PushPackage()
        {
            DiagnosticsClient.TrackEvent("PushPackage");

            ShowProgress = true;
            Status       = (PublishAsUnlisted == true) ? "Publishing and unlisting package..." : "Publishing package...";
            HasError     = false;
            CanPublish   = false;

            _credentialPublishProvider.PersonalAccessToken = PublishKeyOrPAT;

            try
            {
                var repository     = PackageRepositoryFactory.CreateRepository(PublishUrl);
                var updateResource = await repository.GetResourceAsync <PackageUpdateResource>();

                await updateResource.Push(new[] { _packageFilePath }, null, 999, false, s => PublishKeyOrPAT, s => PublishKeyOrPAT, AppendV2ApiToUrl != true, false, null, NullLogger.Instance);


                if (PublishAsUnlisted == true)
                {
                    await updateResource.Delete(Id, Version, s => PublishKeyOrPAT, s => true, AppendV2ApiToUrl != true, NullLogger.Instance);
                }

                OnCompleted();
            }
            catch (Exception exception)
            {
                OnError(exception);
            }
            finally
            {
                // add the publish url to the list
                _mruSourceManager.NotifyPackageSourceAdded(PublishUrl);

                _credentialPublishProvider.PersonalAccessToken = null;

                // this is to make sure the combo box doesn't goes blank after publishing
                try
                {
                    _suppressReadingApiKey = true;
                    SelectedPublishItem    = PublishUrl;
                }
                finally
                {
                    _suppressReadingApiKey = false;
                }
            }
        }
        private async void ChangePackageSource(string source)
        {
            if (PackageSource != source)
            {
                // add the new source to MRU list
                _packageSourceManager.NotifyPackageSourceAdded(source);
                PackageSource = source;

                ResetPackageRepository();
                await LoadPackages();
            }
            else
            {
                await LoadPackages();
            }
        }