-
-
Notifications
You must be signed in to change notification settings - Fork 745
Expand file tree
/
Copy pathPrintItemMetadata.cs
More file actions
39 lines (35 loc) · 1.18 KB
/
PrintItemMetadata.cs
File metadata and controls
39 lines (35 loc) · 1.18 KB
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
37
38
39
namespace ElectronNET.Build
{
using System;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
public class DumpItemMetadataTask : Task
{
// The item group whose metadata will be dumped.
[Required]
public ITaskItem[] Items { get; set; }
public override bool Execute()
{
try
{
foreach (var item in this.Items)
{
// Log the item's identity (the Include attribute)
this.Log.LogMessage(MessageImportance.High, $"Item: {item.ItemSpec}");
// Iterate through each metadata field of the item.
foreach (string metadataName in item.MetadataNames)
{
string metadataValue = item.GetMetadata(metadataName);
this.Log.LogMessage(MessageImportance.High, $" {metadataName}: {metadataValue}");
}
}
return true;
}
catch (Exception ex)
{
this.Log.LogErrorFromException(ex);
return false;
}
}
}
}