代码之家  ›  专栏  ›  技术社区  ›  Andrew Russell

XNA内容项目中内容的通配符?

  •  1
  • Andrew Russell  · 技术社区  · 15 年前

    我有一个XNA 3.1内容项目(.contentproj),包含以下内容:

    <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 而是编译-这样当我从“tiles”目录添加和删除纹理时,就不必继续重新同步内容项目。

    有人知道怎么做吗?

    2 回复  |  直到 15 年前
        1
  •  3
  •   Julien Hoarau    15 年前

    您必须在项目定义中使用通配符:

    <ItemGroup>
      <Compile Include="tiles\**\*.BMP"
               Exclude="tiles\.svn\*">
        <Name>%(Compile.Filename)</Name>
        <Importer>TextureImporter</Importer>
        <Processor>TextureProcessor</Processor>
      </Compile>
    </ItemGroup>
    
        2
  •  2
  •   Andrew Russell    15 年前

    我发现Shawn Hargreaves的一篇博客文章描述了如何为XNA 1.0做到这一点:

    Wildcard content using MSBuild

    基于此,下面是我在XNA3.1中所做的工作(不会导致那些奇怪的0出现):

    使用以下内容创建一个单独的“tiles.proj”文件:

    <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> ,添加:

    <Import Project="tiles.proj" />