private static BuildModel CreateModel(IEnumerable <BlobArtifactModel> blobArtifacts, IEnumerable <PackageArtifactModel> packageArtifacts, string manifestBuildId, string[] manifestBuildData, string manifestRepoUri, string manifestBranch, string manifestCommit, bool isStableBuild, TaskLoggingHelper log) { var attributes = MSBuildListSplitter.GetNamedProperties(manifestBuildData); if (!ManifestBuildDataHasLocationProperty(attributes)) { log.LogError($"Missing 'location' property from ManifestBuildData"); } BuildModel buildModel = new BuildModel( new BuildIdentity { Attributes = attributes, Name = manifestRepoUri, BuildId = manifestBuildId, Branch = manifestBranch, Commit = manifestCommit, IsStable = isStableBuild.ToString() }); buildModel.Artifacts.Blobs.AddRange(blobArtifacts); buildModel.Artifacts.Packages.AddRange(packageArtifacts); return(buildModel); }
public PackageArtifactModel CreatePackageArtifactModel(ITaskItem item) { _log.LogMessage($"Creating NupkgInfo based on '{item.ItemSpec}'"); NupkgInfo info = _nupkgInfoFactory.CreateNupkgInfo(item.ItemSpec); return(new PackageArtifactModel { Attributes = MSBuildListSplitter.GetNamedProperties(item.GetMetadata("ManifestArtifactData")), Id = info.Id, Version = info.Version }); }
/// <summary> /// Creates a BlobArtifactModel based on the datat in the ITaskItem provided. Logs errors that may occur, /// but does not prevent the creation of the BlobArtifactModel. Errors do not prevent the creation because /// we want to allow for the capture of all errors that may occur and report back all to the user so they can /// mitigate all the errors found instead of one at a time, which would require continual re-runs of this code /// in order to find it. /// </summary> /// <param name="item"></param> /// <param name="log"></param> /// <returns></returns> public BlobArtifactModel CreateBlobArtifactModel(ITaskItem item) { string path = item.GetMetadata("RelativeBlobPath"); if (string.IsNullOrEmpty(path)) { _log.LogError($"Missing 'RelativeBlobPath' property on blob {item.ItemSpec}"); } return(new BlobArtifactModel { Attributes = MSBuildListSplitter.GetNamedProperties(item.GetMetadata("ManifestArtifactData")), Id = path }); }
private BuildModel CreateModel( IEnumerable <BlobArtifactModel> blobArtifacts, IEnumerable <PackageArtifactModel> packageArtifacts, string manifestBuildId, string[] manifestBuildData, string manifestRepoName, string manifestBranch, string manifestCommit, bool isStableBuild, PublishingInfraVersion publishingVersion, bool isReleaseOnlyPackageVersion, SigningInformationModel signingInformationModel = null) { var attributes = MSBuildListSplitter.GetNamedProperties(manifestBuildData); if (!ManifestBuildDataHasLocationInformation(attributes)) { _log.LogError("Missing 'location' property from ManifestBuildData"); } NormalizeUrisInBuildData(attributes); BuildModel buildModel = new BuildModel( new BuildIdentity { Attributes = attributes, Name = manifestRepoName, BuildId = manifestBuildId, Branch = manifestBranch, Commit = manifestCommit, IsStable = isStableBuild, PublishingVersion = publishingVersion, IsReleaseOnlyPackageVersion = isReleaseOnlyPackageVersion }); buildModel.Artifacts.Blobs.AddRange(blobArtifacts); buildModel.Artifacts.Packages.AddRange(packageArtifacts); buildModel.SigningInformation = signingInformationModel; return(buildModel); }
private static BuildModel CreateModel(IEnumerable <BlobArtifactModel> blobArtifacts, IEnumerable <PackageArtifactModel> packageArtifacts, string manifestBuildId, string[] manifestBuildData, string manifestRepoUri, string manifestBranch, string manifestCommit) { BuildModel buildModel = new BuildModel( new BuildIdentity { Attributes = MSBuildListSplitter.GetNamedProperties(manifestBuildData), Name = manifestRepoUri, BuildId = manifestBuildId, Branch = manifestBranch, Commit = manifestCommit }); buildModel.Artifacts.Blobs.AddRange(blobArtifacts); buildModel.Artifacts.Packages.AddRange(packageArtifacts); return(buildModel); }
private static IDictionary <string, string> ParseCustomAttributes(ITaskItem item) { return(MSBuildListSplitter.GetNamedProperties(item.GetMetadata("ManifestArtifactData"))); }
internal static bool ManifestBuildDataHasLocationProperty(string [] manifestBuildData) { return(ManifestBuildDataHasLocationProperty(MSBuildListSplitter.GetNamedProperties(manifestBuildData))); }
private 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 if (string.IsNullOrWhiteSpace(ExpectedFeedUrl) || string.IsNullOrWhiteSpace(AccountKey)) { Log.LogError($"{nameof(ExpectedFeedUrl)} / {nameof(AccountKey)} is not set properly."); } else if (string.IsNullOrWhiteSpace(AssetManifestPath)) { Log.LogError($"{nameof(AssetManifestPath)} is not set properly."); } else if (MaxClients <= 0) { Log.LogError($"{nameof(MaxClients)} should be greater than zero."); } else if (UploadTimeoutInMinutes <= 0) { Log.LogError($"{nameof(UploadTimeoutInMinutes)} should be greater than zero."); } if (Log.HasLoggedErrors) { return(false); } BlobFeedAction blobFeedAction = new BlobFeedAction(ExpectedFeedUrl, AccountKey, Log); var pushOptions = new PushOptions { AllowOverwrite = Overwrite, PassIfExistingItemIdentical = PassIfExistingItemIdentical }; IEnumerable <BlobArtifactModel> blobArtifacts = Enumerable.Empty <BlobArtifactModel>(); IEnumerable <PackageArtifactModel> packageArtifacts = Enumerable.Empty <PackageArtifactModel>(); if (!SkipCreateContainer) { await blobFeedAction.CreateContainerAsync(BuildEngine, PublishFlatContainer); } if (PublishFlatContainer) { await blobFeedAction.PublishToFlatContainerAsync(ItemsToPush, MaxClients, pushOptions); blobArtifacts = ConcatBlobArtifacts(blobArtifacts, ItemsToPush); } else { ITaskItem[] symbolItems = ItemsToPush .Where(i => i.ItemSpec.Contains("symbols.nupkg")) .Select(i => { string fileName = Path.GetFileName(i.ItemSpec); i.SetMetadata("RelativeBlobPath", $"{AssetsVirtualDir}symbols/{fileName}"); return(i); }) .ToArray(); ITaskItem[] packageItems = ItemsToPush .Where(i => !symbolItems.Contains(i)) .ToArray(); var packagePaths = packageItems.Select(i => i.ItemSpec); if (!blobFeedAction.PushToFeedAsync(packagePaths, pushOptions).Result) { return(!Log.HasLoggedErrors); } await blobFeedAction.PublishToFlatContainerAsync(symbolItems, MaxClients, pushOptions); if (Log.HasLoggedErrors) { return(!Log.HasLoggedErrors); } packageArtifacts = ConcatPackageArtifacts(packageArtifacts, packageItems); blobArtifacts = ConcatBlobArtifacts(blobArtifacts, symbolItems); } if (!(MSBuildListSplitter.GetNamedProperties(ManifestBuildData).ContainsKey("Location") || MSBuildListSplitter.GetNamedProperties(ManifestBuildData).ContainsKey("InitialAssetsLocation"))) { string[] locationAttribute = new string[] { $"Location={ExpectedFeedUrl}" }; ManifestBuildData = ManifestBuildData == null ? locationAttribute : ManifestBuildData.Concat(locationAttribute).ToArray(); } _buildModelFactory.CreateBuildManifest( blobArtifacts, packageArtifacts, AssetManifestPath, ManifestRepoUri, ManifestBuildId, ManifestBranch, ManifestCommit, ManifestBuildData, IsStableBuild, PublishingInfraVersion.Legacy, IsReleaseOnlyPackageVersion); } catch (Exception e) { Log.LogErrorFromException(e, true); } return(!Log.HasLoggedErrors); }