Last active
August 29, 2015 14:02
-
-
Save kzu/0bffc2de076aa6e5842c to your computer and use it in GitHub Desktop.
Dump MSBuild Items
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |
<UsingTask TaskName="DumpItems" | |
TaskFactory="CodeTaskFactory" | |
AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v$(MSBuildToolsVersion).dll"> | |
<ParameterGroup> | |
<Items ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="true" /> | |
</ParameterGroup> | |
<Task> | |
<Code Type="Fragment" Language="cs"> | |
<![CDATA[ | |
foreach (var item in Items) | |
{ | |
Log.LogMessage("Item: {0}", item.ItemSpec); | |
foreach (var name in item.MetadataNames.OfType<string>()) | |
{ | |
try | |
{ | |
Log.LogMessage("\t{0}={1}", name, item.GetMetadata(name)); | |
} | |
catch { } | |
} | |
} | |
]]> | |
</Code> | |
</Task> | |
</UsingTask> | |
</Project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Easily dump items and their metadata properties using: