这是一个 MSBuild 脚本:
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="AugmentItemGroup" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<ItemGroup>
<ItmGrp Include="File1.txt">
<Dest>dest\%(FileName)%(Extension)</Dest>
</ItmGrp>
<ItmGrp Include="File2.txt">
<Dest>dest\%(FileName)%(Extension)</Dest>
</ItmGrp>
<ItmGrp Include="File3.txt">
<Dest>dest\%(FileName)%(Extension)</Dest>
</ItmGrp>
</ItemGroup>
<Target Name="AugmentItemGroup">
<ItemGroup>
<ItmGrp Include="File4.txt">
<Dest>dest\%(FileName)%(Extension)</Dest>
</ItmGrp>
</ItemGroup>
<Message Text="%(ItmGrp.FullPath) to %(ItmGrp.Dest)" />
</Target>
</Project>
我期望的输出是:
D:\t\File1.txt to dest\File1.txt
D:\t\File2.txt to dest\File2.txt
D:\t\File3.txt to dest\File3.txt
D:\t\File4.txt to dest\File4.txt
但结果是:
D:\t\File1.txt to dest\File1.txt
D:\t\File2.txt to dest\File2.txt
D:\t\File3.txt to dest\File3.txt
D:\t\File4.txt to dest\File1.txt
D:\t\File4.txt to dest\File2.txt
D:\t\File4.txt to dest\File3.txt
为什么%(FileName)%(Extension)
当 ItemGroup 在目标内时,众所周知的元数据引用的行为会有所不同?
是否有可能在目标内获得“目标外”行为?