MSBuild task does not expand %(Metadata) of TargetOutputs
- Dominant language
- C#
- Stars
- 5.5k
- Forks
- 1.5k
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 133
Description
Invoking the MSBuild task to run a target of the current project does not expand the metadata references in items returned by the target. This is the case only when the new items are created within an ItemGroup as copies of other items for which an ItemDefinitionGroup exists. If the items are copied using an inline task, the metadata is correctly expanded.
### Steps to reproduce
Project file
```xml
%(Filename)bar
new TaskItem(x)).ToArray();
]]>
```
Command line
```msbuild /p:TestCase=ItemGroup```
**or**
```msbuild /p:TestCase=InlineTask```
### Expected behavior
(reproducible using ```TestCase=InlineTask```)
```
Project "D:\test.vcxproj" on node 1 (default targets).
TestMSBuildTask:
%(Foo.Bar)=foobar
Project "D:\test.vcxproj" (1) is building "D:\test.vcxproj" (1:2) on node 1 (MakeFooWithInlineTask target(s)).
MakeFooWithInlineTask:
%(DupFoo.Bar)=foobar
Done Building Project "D:\test.vcxproj" (MakeFooWithInlineTask target(s)).
TestMSBuildTask:
%(DupFoo.Bar)=foobar
Done Building Project "D:\test.vcxproj" (default targets).
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:00.26
```
### Actual behavior
(reproducible with ```TestCase=ItemGroup```)
```
Project "D:\test.vcxproj" on node 1 (default targets).
TestMSBuildTask:
%(Foo.Bar)=foobar
Project "D:\test.vcxproj" (1) is building "D:\test.vcxproj" (1:2) on node 1 (MakeFooWithItemGroup target(s)).
MakeFooWithItemGroup:
%(DupFoo.Bar)=foobar
Done Building Project "D:\test.vcxproj" (MakeFooWithItemGroup target(s)).
TestMSBuildTask:
%(DupFoo.Bar)=%(Filename)bar
Done Building Project "D:\test.vcxproj" (default targets).
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:00.08
```
### Environment data
`msbuild /version` output: 15.9.21.664
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.