// 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.Generic;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using WixToolset.Tools.Core;
///
/// 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(ToolsCommon.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;
}
}
}