Skip to content

Commit

Permalink
Backward-compatibility with KeyValuePair<string, string> metadata ite…
Browse files Browse the repository at this point in the history
…ms (#8870)

Backport #8870 to vs17.7.
  • Loading branch information
jehhynes authored and rainersigwald committed Jul 12, 2023
1 parent 5785ed5 commit 8ebc5ca
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/Build/BackEnd/TaskExecutionHost/TaskExecutionHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1395,9 +1395,15 @@ private void GatherTaskItemOutputs(bool outputTargetIsItem, string outputTargetN
// Setting an item spec expects the escaped value, as does setting metadata.
newItem = new ProjectItemInstance(_projectInstance, outputTargetName, EscapingUtilities.Escape(output.ItemSpec), parameterLocationEscaped);

newItem.SetMetadataOnTaskOutput(output.CloneCustomMetadata()
.Cast<DictionaryEntry>()
.Select(x => new KeyValuePair<string, string>((string)x.Key, EscapingUtilities.Escape((string)x.Value))));
newItem.SetMetadataOnTaskOutput(EnumerateMetadata(output.CloneCustomMetadata()));

static IEnumerable<KeyValuePair<string, string>> EnumerateMetadata(IDictionary customMetadata)
{
foreach (DictionaryEntry de in customMetadata)
{
yield return new KeyValuePair<string, string>((string)de.Key, EscapingUtilities.Escape((string)de.Value));
}
}
}
}

Expand Down

0 comments on commit 8ebc5ca

Please sign in to comment.