forked from dotnet/sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GetPublishItemsOutputGroupOutputs.cs
36 lines (31 loc) · 1.37 KB
/
GetPublishItemsOutputGroupOutputs.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
namespace Microsoft.NET.Build.Tasks
{
public sealed class GetPublishItemsOutputGroupOutputs : TaskBase
{
public ITaskItem[] ResolvedFileToPublish { get; set; }
public string PublishDir { get; set; }
[Output]
public ITaskItem[] PublishItemsOutputGroupOutputs { get; private set; }
protected override void ExecuteCore()
{
var list = new List<ITaskItem>();
if (ResolvedFileToPublish != null)
{
foreach (var r in ResolvedFileToPublish)
{
var newItem = new TaskItem(r.GetMetadata("FullPath"));
r.CopyMetadataTo(newItem);
newItem.SetMetadata(metadataName: MetadataKeys.TargetPath, metadataValue: r.GetMetadata(MetadataKeys.RelativePath));
newItem.SetMetadata(metadataName: "OutputPath", (PublishDir ?? "") + r.GetMetadata(MetadataKeys.RelativePath));
newItem.SetMetadata(metadataName: "OutputGroup", "PublishItemsOutputGroup");
list.Add(newItem);
}
}
PublishItemsOutputGroupOutputs = list.ToArray();
}
}
}