XNA内容项目中内容的通配符? [英] Wildcard for content in an XNA content project?
问题描述
我有一个XNA 3.1内容项目(.contentproj),其内容如下:
I have an XNA 3.1 content project (.contentproj) with the following:
<ItemGroup>
<Compile Include="tiles\B000N800.BMP">
<Name>B000N800</Name>
<Importer>TextureImporter</Importer>
<Processor>TextureProcessor</Processor>
</Compile>
<Compile Include="tiles\B000N801.BMP">
<Name>B000N801</Name>
<Importer>TextureImporter</Importer>
<Processor>TextureProcessor</Processor>
</Compile>
(... and so on ...)
</ItemGroup>
我想做的是能够指定一个通配符,以便改为编译tiles\*.bmp
-这样,当我在瓷砖"目录.
What I'd like to do is be able to specify a wildcard so that tiles\*.bmp
gets compiled instead - so that I don't have to keep re-synchronising the content project when I add and remove textures from the "tiles" directory.
有人知道这样做的方法吗?
Does anyone know a way to do this?
理想情况下,解决方案将忽略"tiles"下隐藏的".svn"目录.内容项目也将继续在Visual Studio中工作.
Ideally the solution would ignore the hidden ".svn" directory, under "tiles". And also the content project would continue to work in Visual Studio.
推荐答案
我找到了Shawn Hargreaves的博客文章,其中描述了如何针对XNA 1.0做到这一点:
I found a blog post by Shawn Hargreaves that describes how to do this for XNA 1.0:
基于此,这是我在XNA 3.1上所做的工作(并且不会导致那些奇怪的_0出现):
Based on that, here is what I did which works with XNA 3.1 (and doesn't cause those weird _0 to appear):
使用以下内容创建单独的"tiles.proj"文件:
Create a separate "tiles.proj" file with the following content:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
<ItemGroup>
<WildcardContent Include="tiles\**\*.BMP" Exclude="tiles\.svn\*">
<Importer>TextureImporter</Importer>
<Processor>TextureProcessor</Processor>
</WildcardContent>
</ItemGroup>
<Target Name="BeforeBuild">
<CreateItem Include="@(WildcardContent)" AdditionalMetadata="Name=%(FileName)">
<Output TaskParameter="Include" ItemName="Compile" />
</CreateItem>
</Target>
</Project>
在</Project>
之前的原始".contentproj"文件中,添加:
And in the original ".contentproj" file, right before </Project>
, add:
<Import Project="tiles.proj" />
这篇关于XNA内容项目中内容的通配符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!