From d3d3649a68cb1fa589fdd987a6690dbd5d671f0d Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Sun, 17 Sep 2017 15:35:20 -0700 Subject: Initial code commit --- src/WixToolset.BuildTasks/ConvertReferences.cs | 93 ++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 src/WixToolset.BuildTasks/ConvertReferences.cs (limited to 'src/WixToolset.BuildTasks/ConvertReferences.cs') diff --git a/src/WixToolset.BuildTasks/ConvertReferences.cs b/src/WixToolset.BuildTasks/ConvertReferences.cs new file mode 100644 index 00000000..fe137633 --- /dev/null +++ b/src/WixToolset.BuildTasks/ConvertReferences.cs @@ -0,0 +1,93 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.BuildTasks +{ + using System; + using System.Collections; + using System.Collections.Generic; + using System.Globalization; + using System.IO; + using System.Xml; + using Microsoft.Build.Framework; + using Microsoft.Build.Utilities; + + /// + /// This task assigns Culture metadata to files based on the value of the Culture attribute on the + /// WixLocalization element inside the file. + /// + public class ConvertReferences : Task + { + private string projectOutputGroups; + private ITaskItem[] projectReferences; + private ITaskItem[] harvestItems; + + /// + /// The total list of cabs in this database + /// + [Output] + public ITaskItem[] HarvestItems + { + get { return this.harvestItems; } + } + + /// + /// The project output groups to harvest. + /// + [Required] + public string ProjectOutputGroups + { + get { return this.projectOutputGroups; } + set { this.projectOutputGroups = value; } + } + + /// + /// All the project references in the project. + /// + [Required] + public ITaskItem[] ProjectReferences + { + get { return this.projectReferences; } + set { this.projectReferences = value; } + } + + /// + /// Gets a complete list of external cabs referenced by the given installer database file. + /// + /// True upon completion of the task execution. + public override bool Execute() + { + List newItems = new List(); + + foreach(ITaskItem item in this.ProjectReferences) + { + Dictionary newItemMetadeta = new Dictionary(); + + if (!String.IsNullOrEmpty(item.GetMetadata(Common.DoNotHarvest))) + { + continue; + } + + string refTargetDir = item.GetMetadata("RefTargetDir"); + if (!String.IsNullOrEmpty(refTargetDir)) + { + newItemMetadeta.Add("DirectoryIds", refTargetDir); + } + + string refName = item.GetMetadata("Name"); + if (!String.IsNullOrEmpty(refName)) + { + newItemMetadeta.Add("ProjectName", refName); + } + + newItemMetadeta.Add("ProjectOutputGroups", this.ProjectOutputGroups); + + ITaskItem newItem = new TaskItem(item.ItemSpec, newItemMetadeta); + newItems.Add(newItem); + } + + this.harvestItems = newItems.ToArray(); + + return true; + } + } +} -- cgit v1.2.3-55-g6feb