diff --git a/build/Publish.targets b/build/Publish.targets index 2fbe87c07e..88c6ae41c0 100644 --- a/build/Publish.targets +++ b/build/Publish.targets @@ -13,7 +13,7 @@ ResolveCommitHash; PrepareOutputPaths; GetFilesToPublish; - CopyToPublishArtifacts; + PublishToLocalFolder; PublishToAzureFeed; PublishToTransportFeed; PublishToMyGet; @@ -47,7 +47,7 @@ Overwrite="true" /> - + - - - - - - + @@ -170,8 +163,10 @@ - + + + $(CleanDependsOn);CleanArtifacts;CleanUniverseArtifacts $(RestoreDependsOn);InstallDotNet $(CompileDependsOn);BuildRepositories - $(PackageDependsOn);BuildMetapackages;BuildTemplates;SplitPackages + $(PackageDependsOn);BuildMetapackages;BuildTemplates;CheckExpectedPackagesExist $(TestDependsOn);_TestRepositories $(VerifyDependsOn);VerifyCoherentVersions $(GetArtifactInfoDependsOn);ResolveRepoInfo;GetLineupPackageInfo @@ -164,18 +164,6 @@ - - - - - - - - @@ -212,6 +200,14 @@ ExternalDependencies="@(ExternalDependency);@(ShippedExternalDependency)" /> + + + + + + + + diff --git a/build/tasks/CheckExpectedPackagesExist.cs b/build/tasks/CheckExpectedPackagesExist.cs new file mode 100644 index 0000000000..0df55e5d47 --- /dev/null +++ b/build/tasks/CheckExpectedPackagesExist.cs @@ -0,0 +1,69 @@ +// 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.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using Microsoft.Build.Framework; +using NuGet.Packaging; +using NuGet.Packaging.Core; +using RepoTasks.Utilities; + +namespace RepoTasks +{ + public class CheckExpectedPackagesExist : Microsoft.Build.Utilities.Task + { + /// + /// The item group containing the nuget packages to split in different folders. + /// + [Required] + public ITaskItem[] Packages { get; set; } + + [Required] + public ITaskItem[] Files { get; set; } + + public override bool Execute() + { + if (Files?.Length == 0) + { + Log.LogError("No packages were found."); + return false; + } + + var expectedPackages = new HashSet(Packages.Select(i => i.ItemSpec), StringComparer.OrdinalIgnoreCase); + + foreach (var file in Files) + { + PackageIdentity identity; + using (var reader = new PackageArchiveReader(file.ItemSpec)) + { + identity = reader.GetIdentity(); + } + + if (!expectedPackages.Contains(identity.Id)) + { + Log.LogError($"Unexpected package artifact with id: {identity.Id}"); + continue; + } + + expectedPackages.Remove(identity.Id); + } + + if (expectedPackages.Count != 0) + { + var error = new StringBuilder(); + foreach (var id in expectedPackages) + { + error.Append(" - ").AppendLine(id); + } + + Log.LogError($"Expected the following packages, but they were not found:" + error.ToString()); + return false; + } + + return !Log.HasLoggedErrors; + } + } +} diff --git a/build/tasks/CopyPackagesToSplitFolders.cs b/build/tasks/CopyPackagesToSplitFolders.cs deleted file mode 100644 index 22f2f24df4..0000000000 --- a/build/tasks/CopyPackagesToSplitFolders.cs +++ /dev/null @@ -1,116 +0,0 @@ -// 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.IO; -using System.Text; -using Microsoft.Build.Framework; -using NuGet.Packaging; -using NuGet.Packaging.Core; -using RepoTasks.Utilities; - -namespace RepoTasks -{ - public class CopyPackagesToSplitFolders : Microsoft.Build.Utilities.Task - { - /// - /// The item group containing the nuget packages to split in different folders. - /// - [Required] - public ITaskItem[] Packages { get; set; } - - [Required] - public ITaskItem[] Files { get; set; } - - /// - /// The folder where packages should be copied. Subfolders will be created based on package category. - /// - [Required] - public string DestinationFolder { get; set; } - - public bool Overwrite { get; set; } - - public override bool Execute() - { - if (Files?.Length == 0) - { - Log.LogError("No packages were found."); - return false; - } - - var expectedPackages = PackageCollection.FromItemGroup(Packages); - - Directory.CreateDirectory(DestinationFolder); - - foreach (var file in Files) - { - PackageIdentity identity; - using (var reader = new PackageArchiveReader(file.ItemSpec)) - { - identity = reader.GetIdentity(); - } - - var isSymbolsPackage = file.ItemSpec.EndsWith(".symbols.nupkg", StringComparison.OrdinalIgnoreCase); - PackageCategory category; - if (isSymbolsPackage) - { - category = PackageCategory.Symbols; - } - else if (!expectedPackages.TryGetCategory(identity.Id, out category)) - { - Log.LogError($"Unexpected package artifact with id: {identity.Id}"); - continue; - } - - string destDir; - switch (category) - { - case PackageCategory.Unknown: - throw new InvalidOperationException($"Package {identity} does not have a recognized package category."); - case PackageCategory.Shipping: - destDir = Path.Combine(DestinationFolder, "ship"); - break; - case PackageCategory.NoShip: - destDir = Path.Combine(DestinationFolder, "noship"); - break; - case PackageCategory.ShipOob: - destDir = Path.Combine(DestinationFolder, "shipoob"); - break; - case PackageCategory.Symbols: - destDir = Path.Combine(DestinationFolder, "symbols"); - break; - default: - throw new NotImplementedException(); - } - - Directory.CreateDirectory(destDir); - - var destFile = Path.Combine(destDir, Path.GetFileName(file.ItemSpec)); - - if (!Overwrite && File.Exists(destFile)) - { - Log.LogError($"File already exists in {destFile}"); - continue; - } - - Log.LogMessage($"Copying {file.ItemSpec} to {destFile}"); - File.Copy(file.ItemSpec, destFile, Overwrite); - expectedPackages.Remove(identity.Id); - } - - if (expectedPackages.Count != 0) - { - var error = new StringBuilder(); - foreach (var key in expectedPackages.Keys) - { - error.Append(" - ").AppendLine(key); - } - - Log.LogError($"Expected the following packages, but they were not found:" + error.ToString()); - return false; - } - - return !Log.HasLoggedErrors; - } - } -} diff --git a/build/tasks/RepoTasks.tasks b/build/tasks/RepoTasks.tasks index c91006135b..7e014a92a3 100644 --- a/build/tasks/RepoTasks.tasks +++ b/build/tasks/RepoTasks.tasks @@ -6,7 +6,7 @@ - + diff --git a/build/tasks/Utilities/PackageCategory.cs b/build/tasks/Utilities/PackageCategory.cs deleted file mode 100644 index 19a871d3b6..0000000000 --- a/build/tasks/Utilities/PackageCategory.cs +++ /dev/null @@ -1,15 +0,0 @@ -// 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. - - -namespace RepoTasks.Utilities -{ - public enum PackageCategory - { - Unknown = 0, - Shipping, - NoShip, - ShipOob, - Symbols, - } -} diff --git a/build/tasks/Utilities/PackageCollection.cs b/build/tasks/Utilities/PackageCollection.cs deleted file mode 100644 index 4aa778aa2a..0000000000 --- a/build/tasks/Utilities/PackageCollection.cs +++ /dev/null @@ -1,66 +0,0 @@ -// 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.Collections.Generic; -using System.IO; -using System.Linq; -using Microsoft.Build.Framework; - -namespace RepoTasks.Utilities -{ - public class PackageCollection - { - private readonly IDictionary _packages = new Dictionary(StringComparer.OrdinalIgnoreCase); - - private PackageCollection() - { - } - - public bool TryGetCategory(string packageId, out PackageCategory category) => _packages.TryGetValue(packageId, out category); - - public void Remove(string packageId) => _packages.Remove(packageId); - - public int Count => _packages.Count; - - public IEnumerable Keys => _packages.Keys; - - public static PackageCollection FromItemGroup(ITaskItem[] items) - { - var list = new PackageCollection(); - if (items == null) - { - return list; - } - - foreach (var item in items) - { - PackageCategory category; - switch (item.GetMetadata("Category")?.ToLowerInvariant()) - { - case "ship": - category = PackageCategory.Shipping; - break; - case "noship": - category = PackageCategory.NoShip; - break; - case "shipoob": - category = PackageCategory.ShipOob; - break; - default: - category = PackageCategory.Unknown; - break; - } - - if (list._packages.ContainsKey(item.ItemSpec)) - { - throw new InvalidDataException($"Duplicate package id detected: {item.ItemSpec}"); - } - - list._packages.Add(item.ItemSpec, category); - } - - return list; - } - } -} diff --git a/modules/DotNetTools b/modules/DotNetTools index 39fc608adb..7e13e83348 160000 --- a/modules/DotNetTools +++ b/modules/DotNetTools @@ -1 +1 @@ -Subproject commit 39fc608adb59987e6a97f4d482a2544ebfda7924 +Subproject commit 7e13e83348bea331ee8943c6649b27a681e872af diff --git a/modules/Scaffolding b/modules/Scaffolding index 3b441e1709..18060e0ace 160000 --- a/modules/Scaffolding +++ b/modules/Scaffolding @@ -1 +1 @@ -Subproject commit 3b441e17095f34b80be53bee28729d2619cc461c +Subproject commit 18060e0ace1f643b57c49fd4fa2443dd14e006db