我正在尝试ItemGroup
使用目录基本名称填充一个,通过转换将其传递以从它们创建绝对路径并导入驻留在那里的文件。它在Message
元素中完美运行,但在Import
. 我错过了什么?
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<MyDependencies Include="Dir1" />
<MyDependencies Include="Dir2" />
</ItemGroup>
<!-- "Expansion: C:\path\Dir1\import.targets;C:\some\path\Dir2\import.targets" -->
<Target Name="TestMessage" BeforeTargets="PrepareForBuild">
<Message
Importance="High"
Text="Expansion: @(MyDependencies -> 'C:\path\%(Identity)\import.targets')"
/>
</Target>
<!-- Uncomment to trigger error -->
<!--<Import Project="@(MyDependencies -> 'C:\path\%(Identity)\import.targets')" />-->
</Project>
的Import
路径保持未扩展并导致:
error MSB4102: The value "@(MyDependencies -> 'C:\path\%(Identity)\import.targets')" of the "Project" attribute in element <Import> is invalid. Illegal characters in path.