diff options
Diffstat (limited to 'src/WixToolset.BuildTasks/ConvertReferences.cs')
| -rw-r--r-- | src/WixToolset.BuildTasks/ConvertReferences.cs | 93 |
1 files changed, 93 insertions, 0 deletions
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 @@ | |||
| 1 | // 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. | ||
| 2 | |||
| 3 | namespace WixToolset.BuildTasks | ||
| 4 | { | ||
| 5 | using System; | ||
| 6 | using System.Collections; | ||
| 7 | using System.Collections.Generic; | ||
| 8 | using System.Globalization; | ||
| 9 | using System.IO; | ||
| 10 | using System.Xml; | ||
| 11 | using Microsoft.Build.Framework; | ||
| 12 | using Microsoft.Build.Utilities; | ||
| 13 | |||
| 14 | /// <summary> | ||
| 15 | /// This task assigns Culture metadata to files based on the value of the Culture attribute on the | ||
| 16 | /// WixLocalization element inside the file. | ||
| 17 | /// </summary> | ||
| 18 | public class ConvertReferences : Task | ||
| 19 | { | ||
| 20 | private string projectOutputGroups; | ||
| 21 | private ITaskItem[] projectReferences; | ||
| 22 | private ITaskItem[] harvestItems; | ||
| 23 | |||
| 24 | /// <summary> | ||
| 25 | /// The total list of cabs in this database | ||
| 26 | /// </summary> | ||
| 27 | [Output] | ||
| 28 | public ITaskItem[] HarvestItems | ||
| 29 | { | ||
| 30 | get { return this.harvestItems; } | ||
| 31 | } | ||
| 32 | |||
| 33 | /// <summary> | ||
| 34 | /// The project output groups to harvest. | ||
| 35 | /// </summary> | ||
| 36 | [Required] | ||
| 37 | public string ProjectOutputGroups | ||
| 38 | { | ||
| 39 | get { return this.projectOutputGroups; } | ||
| 40 | set { this.projectOutputGroups = value; } | ||
| 41 | } | ||
| 42 | |||
| 43 | /// <summary> | ||
| 44 | /// All the project references in the project. | ||
| 45 | /// </summary> | ||
| 46 | [Required] | ||
| 47 | public ITaskItem[] ProjectReferences | ||
| 48 | { | ||
| 49 | get { return this.projectReferences; } | ||
| 50 | set { this.projectReferences = value; } | ||
| 51 | } | ||
| 52 | |||
| 53 | /// <summary> | ||
| 54 | /// Gets a complete list of external cabs referenced by the given installer database file. | ||
| 55 | /// </summary> | ||
| 56 | /// <returns>True upon completion of the task execution.</returns> | ||
| 57 | public override bool Execute() | ||
| 58 | { | ||
| 59 | List<ITaskItem> newItems = new List<ITaskItem>(); | ||
| 60 | |||
| 61 | foreach(ITaskItem item in this.ProjectReferences) | ||
| 62 | { | ||
| 63 | Dictionary<string, string> newItemMetadeta = new Dictionary<string, string>(); | ||
| 64 | |||
| 65 | if (!String.IsNullOrEmpty(item.GetMetadata(Common.DoNotHarvest))) | ||
| 66 | { | ||
| 67 | continue; | ||
| 68 | } | ||
| 69 | |||
| 70 | string refTargetDir = item.GetMetadata("RefTargetDir"); | ||
| 71 | if (!String.IsNullOrEmpty(refTargetDir)) | ||
| 72 | { | ||
| 73 | newItemMetadeta.Add("DirectoryIds", refTargetDir); | ||
| 74 | } | ||
| 75 | |||
| 76 | string refName = item.GetMetadata("Name"); | ||
| 77 | if (!String.IsNullOrEmpty(refName)) | ||
| 78 | { | ||
| 79 | newItemMetadeta.Add("ProjectName", refName); | ||
| 80 | } | ||
| 81 | |||
| 82 | newItemMetadeta.Add("ProjectOutputGroups", this.ProjectOutputGroups); | ||
| 83 | |||
| 84 | ITaskItem newItem = new TaskItem(item.ItemSpec, newItemMetadeta); | ||
| 85 | newItems.Add(newItem); | ||
| 86 | } | ||
| 87 | |||
| 88 | this.harvestItems = newItems.ToArray(); | ||
| 89 | |||
| 90 | return true; | ||
| 91 | } | ||
| 92 | } | ||
| 93 | } | ||
