Ejemplo n.º 1
0
        /// <summary>
        /// Create the stable packages feed if one is not already explicitly provided
        /// </summary>
        /// <exception cref="Exception">Throws if the feed cannot be created</exception>
        private void CreateStablePackagesFeedIfNeeded()
        {
            if (string.IsNullOrEmpty(StablePackagesFeed))
            {
                var packagesFeedTask = new CreateAzureDevOpsFeed()
                {
                    BuildEngine                    = BuildEngine,
                    AzureDevOpsOrg                 = AzureDevOpsOrg,
                    AzureDevOpsProject             = IsInternalBuild ? "internal" : "public",
                    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;
            }
        }
        private List <TargetFeedConfig> StableFeeds()
        {
            List <TargetFeedConfig> targetFeedConfigs = new List <TargetFeedConfig>();

            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;
            }

            targetFeedConfigs.Add(
                new TargetFeedConfig(
                    TargetFeedContentType.Package,
                    StablePackagesFeed,
                    FeedType.AzDoNugetFeed,
                    AzureDevOpsFeedsKey,
                    assetSelection: AssetSelection.ShippingOnly,
                    symbolTargetType: SymbolTargetType,
                    isolated: true));

            targetFeedConfigs.Add(
                new TargetFeedConfig(
                    TargetFeedContentType.Symbols,
                    StableSymbolsFeed,
                    FeedType.AzDoNugetFeed,
                    AzureDevOpsFeedsKey,
                    symbolTargetType: SymbolTargetType,
                    isolated: true));

            targetFeedConfigs.Add(
                new TargetFeedConfig(
                    TargetFeedContentType.Package,
                    AzureDevOpsStaticTransportFeed,
                    FeedType.AzDoNugetFeed,
                    AzureDevOpsFeedsKey,
                    assetSelection: AssetSelection.NonShippingOnly,
                    symbolTargetType: SymbolTargetType,
                    isolated: false));

            if (PublishInstallersAndChecksums)
            {
                foreach (var contentType in Installers)
                {
                    targetFeedConfigs.Add(
                        new TargetFeedConfig(
                            contentType,
                            InstallersTargetStaticFeed,
                            FeedType.AzureStorageFeed,
                            InstallersAzureAccountKey,
                            isolated: true,
                            symbolTargetType: SymbolTargetType,
                            @internal: false,
                            allowOverwrite: true));
                }

                targetFeedConfigs.Add(
                    new TargetFeedConfig(
                        TargetFeedContentType.Checksum,
                        ChecksumsTargetStaticFeed,
                        FeedType.AzureStorageFeed,
                        ChecksumsAzureAccountKey,
                        isolated: true,
                        symbolTargetType: SymbolTargetType,
                        @internal: false,
                        allowOverwrite: true));
            }

            return(targetFeedConfigs);
        }
Ejemplo n.º 3
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
                                     ));
                }
            }
        }