XNA Creators Club Online
Page 1 of 1 (7 items)
Sort Posts: Previous Next

msbuild dependency compile path

Last post 11/23/2009 5:08 AM by fearlessdolphin. 6 replies.
  • 11/20/2009 11:18 AM

    msbuild dependency compile path

    The msbuild xnb compiler I have setup recursively goes through an asset folder and compiles xnbs in their respective folders, it even creates subfolders when necessary but when compiling dependencies it creates the xnb in the output path instead of placing them inside the model subfolder. In the end I get a bunch of files in the output root instead being in their respective folders. I have managed to get the content type of an xnb using the contentmanager which works quite nicely so I can store model and the depedency files in the same folder so determining the content type isn't an issue.

    What would be even better if I could tell msbuild to create one xnb for all the dependency files. I did some digging in the ContentPipeline.xml which shows and output attribute for every asset but msbuild won't let me modify the output path for builditems.

    I have downloaded shawn's talk about Building Worlds in content pipline, just hadn't had the time to go through it, its very late here and its hard to keep my eyes open!  I just hope I dont have to write a new content processor just to create one xnb or modify the dependency path!


  • 11/20/2009 4:05 PM In reply to

    Re: msbuild dependency compile path

    When adding the files to the MSBuild project, specify the full asset name from the root directory (i.e. "Textures\\2D\\MyTex") to get the assets to be compiled into folders in the output directory.
  • 11/20/2009 5:40 PM In reply to

    Re: msbuild dependency compile path

    I meant the asset in question gets compiled in the right subfolders (i.e. Assets\Models\Automobiles\Cars\Audi") but its dependancies for example texture1.xnb would get saved into the output root i.e. ("Assets\") instead of being saved in (i.e. Assets\Models\Automobiles\Cars\Audi")

    giving it full asset name just puts the model xnb in another subfolder.
  • 11/20/2009 5:55 PM In reply to

    Re: msbuild dependency compile path

    The output folder structure for build outputs is a mirror of the folder structure for the source asset files. If you reference source asset files that are not nested inside the root of your source content folder, their outputs will go in the root of the output.

    I'm guessing that your textures live in some other path that is not a subdirectory of your source content folder?

    If so you have two options:

    • Move the source textures.
    • Or don't worry about it. The directory structure of such indirectly referenced assets is just an implementation detail, and doesn't affect the runtime behavior of your game in any important way.
    XNA Framework Developer - blog - homepage
  • 11/20/2009 7:29 PM In reply to

    Re: msbuild dependency compile path

    The textures reside in the same folder as the model e.g. ("Assets\Models\Cars\Audi\Audi.x"), ("Assets\Models\Cars\Audi\Audi.jpg")

    Here's a snippet from ContentPipeline.xml,

        <Item>
          <Source>C:\Users\user\AppData\Roaming\XnaWinformMapEditor\UncompiledAssets\Models\Animals\Tirarex\tirarex.X</Source>
          <Importer>XImporter</Importer>
          <Options>IntermediateFile, DontCacheImportedData</Options>
          <Output>obj\Release\tirarex_0.xml</Output>
          <Time>2009-11-20T12:03:26.3260065-06:00</Time>
        </Item>
        <Item>
          <Source>C:\Users\user\AppData\Roaming\XnaWinformMapEditor\UncompiledAssets\Models\Animals\Tirarex\GRANDECO.jpg</Source>
          <Importer>TextureImporter</Importer>
          <Processor>TextureProcessor</Processor>
          <Parameters>
            <Data Key="ColorKeyColor" Type="Graphics:Color">FFFF00FF</Data>
            <Data Key="ColorKeyEnabled" Type="bool">true</Data>
            <Data Key="TextureFormat" Type="Processors:TextureProcessorOutputFormat">DxtCompressed</Data>
            <Data Key="GenerateMipmaps" Type="bool">true</Data>
            <Data Key="ResizeToPowerOfTwo" Type="bool">true</Data>
          </Parameters>
          <Options>None</Options>
          <Output>C:\Users\user\AppData\Roaming\XnaWinformMapEditor\Assets\GRANDECO_0.xnb</Output>
          <Time>1995-03-19T06:34:00-05:00</Time>
        </Item>


    I am thinking its how the files are getting added to msBuildItem,

                BuildItem buildItem = msBuildProject.AddNewItem("Compile", source); // source is the full path
                string buildItemPath = Path.GetFullPath(source).Replace(Path.GetFullPath(projectPath), "").Remove(0, 1); // need a better way to calculate nested folder path

                buildItem.SetMetadata("Link", buildItemPath);
                buildItem.SetMetadata("Name", name);

    It's probably as trivial as setting the right metadata...

  • 11/22/2009 7:30 AM In reply to

    Re: msbuild dependency compile path

    hmm... still can't figure out a way to get the texture xnbs to compile in the model xnb subfolders. Basically I have folder that has two subfolders, "Assets" and "UncompiledAssets". The source content folder ("UncompiledAssets") has various types of contents (heightmaps, textures, effects etc) From what I can tell, the source assets are being referenced inside the root source content folders but the modeltextures still get copied over to the output root. I tried using BuildandLoadAsset, but it only compiled the model xnb!
    any help is appreciated
  • 11/23/2009 5:08 AM In reply to

    Re: msbuild dependency compile path

    Answer
    Reply Quote
    After spending couple days studying the content pipline I finally got it. It seems a bit overkill to implement a custom model processor just to adjust the texture paths, but It was great learning experience and now I can write my own importers/processors etc.

Page 1 of 1 (7 items) Previous Next