众所周知的元数据MSBuild 3.5 中的通配符
我目前正在尝试使用 MSBuild 来设置项目,但遇到了一些通配符问题。
我正在尝试使用以下代码片段:
<Project ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Xsd Include="App_Data\*.xsd">
<Generator>MSDataSetGenerator</Generator>
<LastGenOutput>%(Xsd.Filename).Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</Xsd>
<Xss Include="App_Data\*.xss">
<DependentUpon>%(Xss.Filename).xsd</DependentUpon>
</Xss>
<Xsc Include="App_Data\*.xsc">
<DependentUpon>%(Xsc.Filename).xsd</DependentUpon>
</Xsc>
</ItemGroup>
<Target Name="PrintMetaData">
<Message Text="@(Xss->'%(DependentUpon)')"/>
</Target>
</Project>
使用 3.5 版本的 MSBuild 我得到以下输出:
“.xsd;.xsd;.xsd;.....etc.xsd;”
使用 4.0 版本的 MSBuild 我得到了预期的结果:文件名列表。
有谁知道这是否是一个已知的解决方法问题,或者是否有我缺少的 MSBuild 补丁?
谢谢!
I'm currently trying to use MSBuild to set up a project, and am having some issues with wildcards.
I'm trying to use the following snippet:
<Project ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Xsd Include="App_Data\*.xsd">
<Generator>MSDataSetGenerator</Generator>
<LastGenOutput>%(Xsd.Filename).Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</Xsd>
<Xss Include="App_Data\*.xss">
<DependentUpon>%(Xss.Filename).xsd</DependentUpon>
</Xss>
<Xsc Include="App_Data\*.xsc">
<DependentUpon>%(Xsc.Filename).xsd</DependentUpon>
</Xsc>
</ItemGroup>
<Target Name="PrintMetaData">
<Message Text="@(Xss->'%(DependentUpon)')"/>
</Target>
</Project>
using the 3.5 version of MSBuild I get the following output:
".xsd;.xsd;.xsd;.....etc.xsd;"
using the 4.0 version of MSBuild I get the expected result: a list of the filenames.
Does anyone know if this is a known issue with a workaround, or if there's a patch for MSBuild I'm missing?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我有一个非常相似的问题。请参阅:MsBuild 中项目的评估范围和顺序 .
使用 4.0 之前的 MSBuild,您无法通过同时批处理其自己众所周知的元数据来声明项目并设置其一些元数据。
也不要忘记,在解析开始时,目标之外的项目会被评估一次。因此,您无法使用 4.0 之前的 MSBuild 在目标之外进行批处理。因此,解决方法可能是将批处理部分(或整个声明放入目标中):
如果您想将整个 ItemGroup 放入目标中,请不要忘记仅在声明项目后通过批处理来设置元数据。您必须分两步完成此操作。
I had a quite similar problem. See : Scope and order of evaluation of Items in MsBuild .
With MSBuild prior to 4.0 you cannot declare an item and set some of his Metadata by batching over its own well-known metadata at the same time.
Don't also forget that Items outside of Targets are evaluated once, in the beginning of the parsing. Thus, you cannot do batching outside of targets with MSBuild prior to 4.0. So a workaround could be to put your batching part (or the whole declaration in your target) :
If you want to put the whole ItemGroup in your target, don't forget to set the metadata by batching only once your item is declared. You must do this in two steps.