Exemplo n.º 1
0
        private IEnumerable <TargetFeedConfig> Feeds()
        {
            // If the build is stable, we need to create two new feeds (if not provided)
            // that can contain stable packages. These packages cannot be pushed to the normal
            // feeds specified in the feed config because it would mean pushing the same package more than once
            // to the same feed on successive builds, which is not allowed.
            if (IsStableBuild)
            {
                CreateStablePackagesFeedIfNeeded();
                CreateStableSymbolsFeedIfNeeded();

                yield return(new TargetFeedConfig(
                                 TargetFeedContentType.Package,
                                 StablePackagesFeed,
                                 FeedType.AzDoNugetFeed,
                                 AzureDevOpsFeedsKey,
                                 LatestLinkShortUrlPrefix,
                                 assetSelection: AssetSelection.ShippingOnly,
                                 symbolTargetType: SymbolTargetType,
                                 isolated: true,
                                 @internal: IsInternalBuild,
                                 filenamesToExclude: FilesToExclude,
                                 flatten: Flatten));

                yield return(new TargetFeedConfig(
                                 TargetFeedContentType.Symbols,
                                 StableSymbolsFeed,
                                 FeedType.AzDoNugetFeed,
                                 AzureDevOpsFeedsKey,
                                 LatestLinkShortUrlPrefix,
                                 symbolTargetType: SymbolTargetType,
                                 isolated: true,
                                 @internal: IsInternalBuild,
                                 filenamesToExclude: FilesToExclude,
                                 flatten: Flatten));
            }

            foreach (var spec in _targetChannelConfig.TargetFeeds)
            {
                foreach (var type in spec.ContentTypes)
                {
                    if (!PublishInstallersAndChecksums)
                    {
                        if (PublishingConstants.InstallersAndChecksums.Contains(type))
                        {
                            continue;
                        }
                    }

                    // If dealing with a stable build, the package feed targeted for shipping packages and symbols
                    // should be skipped, as it is added above.
                    if (IsStableBuild && ((type is TargetFeedContentType.Package && spec.Assets == AssetSelection.ShippingOnly) || type is TargetFeedContentType.Symbols))
                    {
                        continue;
                    }

                    var oldFeed = spec.FeedUrl;
                    var feed    = GetFeedOverride(oldFeed);
                    if (type is TargetFeedContentType.Package &&
                        spec.Assets == AssetSelection.ShippingOnly &&
                        FeedOverrides.TryGetValue("transport-packages", out string newFeed))
                    {
                        feed = newFeed;
                    }
                    else if (type is TargetFeedContentType.Package &&
                             spec.Assets == AssetSelection.NonShippingOnly &&
                             FeedOverrides.TryGetValue("shipping-packages", out newFeed))
                    {
                        feed = newFeed;
                    }
                    var key    = GetFeedKey(feed);
                    var sasUri = GetFeedSasUri(feed);
                    if (feed != oldFeed && string.IsNullOrEmpty(key) && string.IsNullOrEmpty(sasUri))
                    {
                        Log?.LogMessage($"No keys found for {feed}, falling back to keys for {oldFeed}.");
                        // if we used an override, and didn't find a key, fallback to the keys for the non-override value
                        key    = GetFeedKey(oldFeed);
                        sasUri = GetFeedSasUri(oldFeed);
                    }
                    var feedType = feed.StartsWith("https://pkgs.dev.azure.com")
                        ? FeedType.AzDoNugetFeed
                        : (sasUri != null ? FeedType.AzureStorageContainer : FeedType.AzureStorageFeed);
                    yield return(new TargetFeedConfig(
                                     type,
                                     sasUri ?? feed,
                                     feedType,
                                     key,
                                     LatestLinkShortUrlPrefix,
                                     spec.Assets,
                                     false,
                                     IsInternalBuild,
                                     false,
                                     SymbolTargetType,
                                     filenamesToExclude: FilesToExclude,
                                     flatten: Flatten
                                     ));
                }
            }
        }
Exemplo n.º 2
0
        private IEnumerable <TargetFeedConfig> Feeds()
        {
            if (IsStableBuild)
            {
                if (string.IsNullOrEmpty(StablePackagesFeed))
                {
                    var packagesFeedTask = new CreateAzureDevOpsFeed()
                    {
                        BuildEngine = BuildEngine,
                        IsInternal  = IsInternalBuild,
                        AzureDevOpsPersonalAccessToken = AzureDevOpsFeedsKey,
                        RepositoryName = RepositoryName,
                        CommitSha      = CommitSha
                    };

                    if (!packagesFeedTask.Execute())
                    {
                        throw new Exception($"Problems creating an AzureDevOps feed for repository '{RepositoryName}' and commit '{CommitSha}'.");
                    }

                    StablePackagesFeed = packagesFeedTask.TargetFeedURL;
                }

                if (string.IsNullOrEmpty(StableSymbolsFeed))
                {
                    var symbolsFeedTask = new CreateAzureDevOpsFeed()
                    {
                        BuildEngine = BuildEngine,
                        IsInternal  = IsInternalBuild,
                        AzureDevOpsPersonalAccessToken = AzureDevOpsFeedsKey,
                        RepositoryName    = RepositoryName,
                        CommitSha         = CommitSha,
                        ContentIdentifier = "sym"
                    };

                    if (!symbolsFeedTask.Execute())
                    {
                        throw new Exception($"Problems creating an AzureDevOps (symbols) feed for repository '{RepositoryName}' and commit '{CommitSha}'.");
                    }

                    StableSymbolsFeed = symbolsFeedTask.TargetFeedURL;
                }

                yield return(new TargetFeedConfig(
                                 TargetFeedContentType.Package,
                                 StablePackagesFeed,
                                 FeedType.AzDoNugetFeed,
                                 AzureDevOpsFeedsKey,
                                 LatestLinkShortUrlPrefix,
                                 assetSelection: AssetSelection.ShippingOnly,
                                 symbolTargetType: SymbolTargetType,
                                 isolated: true,
                                 @internal: IsInternalBuild,
                                 filenamesToExclude: FilesToExclude,
                                 flatten: Flatten));

                yield return(new TargetFeedConfig(
                                 TargetFeedContentType.Symbols,
                                 StableSymbolsFeed,
                                 FeedType.AzDoNugetFeed,
                                 AzureDevOpsFeedsKey,
                                 LatestLinkShortUrlPrefix,
                                 symbolTargetType: SymbolTargetType,
                                 isolated: true,
                                 @internal: IsInternalBuild,
                                 filenamesToExclude: FilesToExclude,
                                 flatten: Flatten));
            }
            foreach (var spec in _targetChannelConfig.TargetFeeds)
            {
                foreach (var type in spec.ContentTypes)
                {
                    if (!PublishInstallersAndChecksums)
                    {
                        if (PublishingConstants.InstallersAndChecksums.Contains(type))
                        {
                            continue;
                        }
                    }
                    if (IsStableBuild && ((type is TargetFeedContentType.Package && spec.Assets == AssetSelection.ShippingOnly) || type is TargetFeedContentType.Symbols))
                    {
                        // stable build shipping packages and symbols were handled above
                        continue;
                    }

                    var feed = spec.FeedUrl;
                    feed = GetFeedOverride(feed);
                    if (type is TargetFeedContentType.Package &&
                        spec.Assets == AssetSelection.ShippingOnly &&
                        FeedOverrides.TryGetValue("transport-packages", out string newFeed))
                    {
                        feed = newFeed;
                    }
                    else if (type is TargetFeedContentType.Package &&
                             spec.Assets == AssetSelection.NonShippingOnly &&
                             FeedOverrides.TryGetValue("shipping-packages", out newFeed))
                    {
                        feed = newFeed;
                    }
                    var key      = GetFeedKey(feed);
                    var sasUri   = GetFeedSasUri(feed);
                    var feedType = feed.StartsWith("https://pkgs.dev.azure.com")
                        ? FeedType.AzDoNugetFeed
                        : (sasUri != null ? FeedType.AzureStorageContainer : FeedType.AzureStorageFeed);
                    yield return(new TargetFeedConfig(
                                     type,
                                     sasUri ?? feed,
                                     feedType,
                                     key,
                                     LatestLinkShortUrlPrefix,
                                     spec.Assets,
                                     false,
                                     IsInternalBuild,
                                     false,
                                     filenamesToExclude: FilesToExclude,
                                     flatten: Flatten
                                     ));
                }
            }
        }