using System; using System.IO; using System.Linq; using System.Collections.Generic; using Microsoft.Build.Utilities; using Microsoft.Build.Framework; namespace ILLink.Tasks { public class ComputeRemovedAssemblies : Task { /// /// The paths to the inputs to the linker. /// [Required] public ITaskItem[] InputAssemblies { get; set; } /// /// The paths to the linked assemblies. /// [Required] public ITaskItem[] KeptAssemblies { get; set; } /// /// The set of assemblies in the inputs that weren't kept by /// the linker. These items include the full metadata from /// the input assemblies, and only the filenames of the /// inputs are used to determine which assemblies were /// removed. /// [Output] public ITaskItem[] RemovedAssemblies { get; set; } public override bool Execute() { var keptAssemblyNames = new HashSet ( KeptAssemblies.Select(i => Path.GetFileName(i.ItemSpec)) ); RemovedAssemblies = InputAssemblies.Where(i => !keptAssemblyNames.Contains(Path.GetFileName(i.ItemSpec)) ).ToArray(); return true; } } }