我正在尝试使用目录基名称填充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.