diff --git a/build/repo.targets b/build/repo.targets index 2f1445b..d9d83f6 100644 --- a/build/repo.targets +++ b/build/repo.targets @@ -175,8 +175,24 @@ - - + + + + + + + aspnetcore-store-$(TimestampVersion)-common.xml + + + + + + + + + + + diff --git a/build/tasks/CreateCommonManifest.cs b/build/tasks/CreateCommonManifest.cs new file mode 100644 index 0000000..4125bbc --- /dev/null +++ b/build/tasks/CreateCommonManifest.cs @@ -0,0 +1,67 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Linq; +using System.Xml; +using Microsoft.Build.Framework; +using Microsoft.Build.Utilities; + +namespace RepoTasks +{ + /// + /// Creates a common manifest file used for trimming publish output given a list of packages and package definitions containing their versions. + /// + public class CreateCommonManifest : Task + { + /// + /// The path for the common manifest file to be created. + /// + /// + [Required] + public string DestinationFilePath { get; set; } + + /// + /// The packages to include in the common manifest file. + /// + /// + [Required] + public ITaskItem[] Packages { get; set; } + + /// + /// The package definitions used for resolving package versions. + /// + /// + [Required] + public ITaskItem[] PackageDefinitions { get; set; } + + public override bool Execute() + { + var xmlDoc = new XmlDocument(); + var packagesElement = xmlDoc.CreateElement("StoreArtifacts"); + + foreach (var package in Packages) + { + var packageName = package.ItemSpec; + var packageElement = xmlDoc.CreateElement("Package"); + + var idAttribute = xmlDoc.CreateAttribute("Id"); + idAttribute.Value = packageName; + packageElement.Attributes.Append(idAttribute); + + var versionAttribute = xmlDoc.CreateAttribute("Version"); + versionAttribute.Value = PackageDefinitions + .Where(p => string.Equals(p.GetMetadata("Name"), packageName, StringComparison.OrdinalIgnoreCase)) + .Select(p => p.GetMetadata("Version")).Single(); + packageElement.Attributes.Append(versionAttribute); + + packagesElement.AppendChild(packageElement); + } + + xmlDoc.AppendChild(packagesElement); + xmlDoc.Save(DestinationFilePath); + + return true; + } + } +} diff --git a/build/tasks/RepoTasks.csproj b/build/tasks/RepoTasks.csproj new file mode 100644 index 0000000..f18ec7a --- /dev/null +++ b/build/tasks/RepoTasks.csproj @@ -0,0 +1,9 @@ + + + + + netcoreapp2.0 + + + + diff --git a/build/tasks/RepoTasks.tasks b/build/tasks/RepoTasks.tasks new file mode 100644 index 0000000..5de9828 --- /dev/null +++ b/build/tasks/RepoTasks.tasks @@ -0,0 +1,3 @@ + + + diff --git a/tools/Build.RuntimeStore.References/Build.RuntimeStore.References.csproj b/tools/Build.RuntimeStore.References/Build.RuntimeStore.References.csproj index 4a3a2ea..cb2a844 100644 --- a/tools/Build.RuntimeStore.References/Build.RuntimeStore.References.csproj +++ b/tools/Build.RuntimeStore.References/Build.RuntimeStore.References.csproj @@ -1,5 +1,7 @@  + + @@ -8,6 +10,13 @@ - + + + + + + + +