public AzureDevOpsNugetFeedAssetPublisher(TaskLoggingHelper log, string targetUrl, string accessToken, PublishArtifactsInManifestBase task)
        {
            _log         = log;
            _targetUrl   = targetUrl;
            _accessToken = accessToken;
            _task        = task;

            var parsedUri = Regex.Match(_targetUrl, PublishingConstants.AzDoNuGetFeedPattern);

            if (!parsedUri.Success)
            {
                throw new ArgumentException(
                          $"Azure DevOps NuGetFeed was not in the expected format '{PublishingConstants.AzDoNuGetFeedPattern}'");
            }
            _feedAccount    = parsedUri.Groups["account"].Value;
            _feedVisibility = parsedUri.Groups["visibility"].Value;
            _feedName       = parsedUri.Groups["feed"].Value;

            _httpClient = new HttpClient(new HttpClientHandler {
                CheckCertificateRevocationList = true
            })
            {
                Timeout = GeneralUtils.NugetFeedPublisherHttpClientTimeout,
                DefaultRequestHeaders =
                {
                    Authorization = new AuthenticationHeaderValue(
                        "Basic",
                        Convert.ToBase64String(Encoding.ASCII.GetBytes($":{_accessToken}")))
                },
            };
        }
예제 #2
0
        public virtual IAssetPublisher CreateAssetPublisher(TargetFeedConfig feedConfig, PublishArtifactsInManifestBase task)
        {
            switch (feedConfig.Type)
            {
            case FeedType.AzDoNugetFeed:
                return(new AzureDevOpsNugetFeedAssetPublisher(_log, feedConfig.TargetURL, feedConfig.Token, task));

            case FeedType.AzureStorageFeed:
                var action = new BlobFeedAction(feedConfig.TargetURL, feedConfig.Token, _log);
                return(new AzureStorageFeedAssetPublisher(action.AccountName, action.AccountKey, action.ContainerName, _log));

            case FeedType.AzureStorageContainer:
                return(new AzureStorageContainerAssetPublisher(new Uri(feedConfig.TargetURL), _log));

            default:
                throw new NotImplementedException();
            }
        }