| 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.Generic; |
| 7 | using System.Linq; |
| 8 | using Microsoft.Build.Framework; |
| 9 | using Microsoft.Build.Utilities; |
| 10 | |
| 11 | /// <summary> |
| 12 | /// This task creates items from properties without triggering the item creation inference |
| 13 | /// MSBuild targets will normally do. There are very specialized cases where this is used. |
| 14 | /// </summary> |
| 15 | public class CreateItemAvoidingInference : Task |
| 16 | { |
| 17 | /// <summary> |
| 18 | /// The properties to convert into items. |
| 19 | /// </summary> |
| 20 | [Required] |
| 21 | public string InputProperties { get; set; } |
| 22 | |
| 23 | /// <summary> |
| 24 | /// The output items. |
| 25 | /// </summary> |
| 26 | [Output] |
| 27 | public ITaskItem[] OutputItems { get; private set; } |
| 28 | |
| 29 | /// <summary> |
| 30 | /// Convert the input properties into output items. |
| 31 | /// </summary> |
| 32 | /// <returns>True upon completion of the task execution.</returns> |
| 33 | public override bool Execute() |
| 34 | { |
| 35 | this.OutputItems = this.InputProperties |
| 36 | .Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries) |
| 37 | .Select(property => new TaskItem(property)) |
| 38 | .ToArray(); |
| 39 | |
| 40 | return true; |
| 41 | } |
| 42 | } |
| 43 | } |