We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When you use %(Item.Identity) syntax then MSBuild creates new item with the same Identity. So, all other metadata is lost!
%(Item.Identity)
MSBuild
Identity
<PrintItem Reference="%(ReferencePath.Identity)" /> // Metadata is lost <UsingTask TaskName="PrintItem" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll"> <ParameterGroup> <Item ParameterType="Microsoft.Build.Framework.ITaskItem" Required="true" /> </ParameterGroup> <Task> <Using Namespace="System" /> <Code Type="Fragment" Language="cs"> <![CDATA[ Log.LogMessage( MessageImportance.High, "Item: {0}", Item ); foreach (var metadata in Item.MetadataNames.Cast<string>()) { Log.LogMessage( MessageImportance.High, "Metadata: {0} = {1}", metadata, Item.GetMetadata( metadata ) ); } ]]> </Code> </Task> </UsingTask> <ItemGroup> <NewItem Include="%(Item.Identity)" /> // Metadata is lost </ItemGroup>
Is there a way to avoid losing metadata?
The text was updated successfully, but these errors were encountered:
This works but looks strange.
<PrintItem Reference="@(ReferencePath)" Condition="%(ReferencePath.Identity) != ''" />
Sorry, something went wrong.
That's the standard idiom.
Ideally the task accepts the list and loops over it -- that is why it looks clunky when you have to pass one at a time.
No branches or pull requests
When you use
%(Item.Identity)
syntax thenMSBuild
creates new item with the sameIdentity
. So, all other metadata is lost!Is there a way to avoid losing metadata?
The text was updated successfully, but these errors were encountered: