Exemplo n.º 1
0
        public async Task <bool> ExecuteAsync()
        {
            Debugger.Launch();
            try
            {
                Log.LogMessage(MessageImportance.High, "Performing feed push...");
                if (ItemsToPush == null)
                {
                    Log.LogError($"No items to push. Please check ItemGroup ItemsToPush.");
                }
                if (string.IsNullOrEmpty(RelativePath))
                {
                    Log.LogWarning($"No relative path. Items are pushed to root of container.");
                }
                BlobFeedAction blobFeedAction  = new BlobFeedAction(AccountName, AccountKey, ContainerName, IndexDirectory, Log);
                bool           containerExists = await blobFeedAction.feed.CheckIfFeedExists();

                if (!containerExists)
                {
                    await blobFeedAction.feed.CreateFeedContainer(RelativePath);
                }
                if (!PublishFlatContainer)
                {
                    if (!containerExists)
                    {
                        await blobFeedAction.PushToFeed(ConvertToStringLists(ItemsToPush), RelativePath);
                    }
                    else
                    {
                        await blobFeedAction.PushToFeed(ConvertToStringLists(ItemsToPush), RelativePath, Overwrite);
                    }
                }
                else
                {
                    await blobFeedAction.PushToFeedFlat(ConvertToStringLists(ItemsToPush), RelativePath, Overwrite);
                }
            }
            catch (Exception e)
            {
                Log.LogErrorFromException(e, true);
            }
            return(!Log.HasLoggedErrors);
        }
Exemplo n.º 2
0
        public async Task <bool> ExecuteAsync()
        {
            try
            {
                Log.LogMessage(MessageImportance.High, "Performing feed push...");
                if (ItemsToPush == null)
                {
                    Log.LogError($"No items to push. Please check ItemGroup ItemsToPush.");
                }
                BlobFeedAction blobFeedAction  = new BlobFeedAction(ExpectedFeedUrl, AccountKey, IndexDirectory, Log);
                bool           containerExists = await blobFeedAction.feed.CheckIfFeedExists();

                if (!containerExists)
                {
                    await blobFeedAction.feed.CreateFeedContainer();
                }
                if (!PublishFlatContainer)
                {
                    if (!containerExists)
                    {
                        await blobFeedAction.PushToFeed(ConvertToStringLists(ItemsToPush));
                    }
                    else
                    {
                        await blobFeedAction.PushToFeed(ConvertToStringLists(ItemsToPush), Overwrite);
                    }
                }
                else
                {
                    await blobFeedAction.PushToFeedFlat(ConvertToStringLists(ItemsToPush), Overwrite);
                }
            }
            catch (Exception e)
            {
                Log.LogErrorFromException(e, true);
            }
            return(!Log.HasLoggedErrors);
        }
Exemplo n.º 3
0
        public async Task <bool> ExecuteAsync()
        {
            try
            {
                Log.LogMessage(MessageImportance.High, "Performing feed push...");

                if (ItemsToPush == null)
                {
                    Log.LogError($"No items to push. Please check ItemGroup ItemsToPush.");
                }
                else
                {
                    BlobFeedAction blobFeedAction = new BlobFeedAction(ExpectedFeedUrl, AccountKey, Log);

                    if (!SkipCreateContainer)
                    {
                        await blobFeedAction.CreateContainerAsync(this.BuildEngine);
                    }

                    List <string> items = ConvertToStringLists(ItemsToPush);

                    if (!PublishFlatContainer)
                    {
                        await blobFeedAction.PushToFeed(items, Overwrite);
                    }
                    else
                    {
                        using (var clientThrottle = new SemaphoreSlim(this.MaxClients, this.MaxClients))
                        {
                            Log.LogMessage($"Uploading {ItemsToPush.Length} items...");
                            await Task.WhenAll(ItemsToPush.Select(item => blobFeedAction.UploadAssets(item, clientThrottle, Overwrite)));
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Log.LogErrorFromException(e, true);
            }

            return(!Log.HasLoggedErrors);
        }
Exemplo n.º 4
0
        public async Task <bool> ExecuteAsync()
        {
            try
            {
                Log.LogMessage(MessageImportance.High, "Performing feed push...");

                if (ItemsToPush == null)
                {
                    Log.LogError($"No items to push. Please check ItemGroup ItemsToPush.");
                }
                else
                {
                    BlobFeedAction blobFeedAction = new BlobFeedAction(ExpectedFeedUrl, AccountKey, Log);

                    IEnumerable <BlobArtifactModel>    blobArtifacts    = Enumerable.Empty <BlobArtifactModel>();
                    IEnumerable <PackageArtifactModel> packageArtifacts = Enumerable.Empty <PackageArtifactModel>();

                    if (!SkipCreateContainer)
                    {
                        await blobFeedAction.CreateContainerAsync(BuildEngine, PublishFlatContainer);
                    }

                    if (PublishFlatContainer)
                    {
                        await PublishToFlatContainerAsync(ItemsToPush, blobFeedAction);

                        blobArtifacts = ConcatBlobArtifacts(blobArtifacts, ItemsToPush);
                    }
                    else
                    {
                        var symbolItems = ItemsToPush.Where(i => i.ItemSpec.Contains("symbols.nupkg")).Select(i =>
                        {
                            string fileName = Path.GetFileName(i.ItemSpec);
                            i.SetMetadata("RelativeBlobPath", $"symbols/{fileName}");
                            return(i);
                        }).ToArray();

                        ITaskItem[] packageItems = ItemsToPush
                                                   .Where(i => !symbolItems.Contains(i))
                                                   .ToArray();

                        var packagePaths = packageItems.Select(i => i.ItemSpec);

                        await blobFeedAction.PushToFeed(packagePaths, Overwrite);
                        await PublishToFlatContainerAsync(symbolItems, blobFeedAction);

                        packageArtifacts = ConcatPackageArtifacts(packageArtifacts, packageItems);
                        blobArtifacts    = ConcatBlobArtifacts(blobArtifacts, symbolItems);
                    }

                    if (!SkipCreateManifest)
                    {
                        await PushBuildManifestAsync(blobFeedAction, blobArtifacts, packageArtifacts);
                    }
                }
            }
            catch (Exception e)
            {
                Log.LogErrorFromException(e, true);
            }

            return(!Log.HasLoggedErrors);
        }