1
votes

I am building a game with XNA, and I have a custom file format for my game's levels. I want to load them and parse them myself, without using XNA's content pipeline. I have this much working, and by adding the files to the Content project I can even edit them in Visual Studio (which I also want).

The Problem: I get a warning stating "Project item 'item.lvl' was not built with the XNA Framework Content Pipeline. Set its Build Action property to Compile to build it."

I do not want XNA to Compile it, since I am doing my own parsing. How can I disable the warning?

2

2 Answers

4
votes

Set the file's Build Action to None, and then set it to Copy if newer. That will cause the file to be written to the proper output directory without putting it through the Content Pipeline.

1
votes

The solution could be create a custom content importer as explained here: Creating a Custom Importer and Processor. To create a simple content importer you have to inherit your class from the ContentImporter<T> (abstract class) and override the Import() method.

Here is a simple example from the msdn:

//...
using Microsoft.Xna.Framework.Content.Pipeline;

class PSSourceCode
{
    const string techniqueCode = "{ pass p0 { PixelShader = compile ps_2_0 main(); } }";

    public PSSourceCode(string sourceCode, string techniqueName)
    {
        this.sourceCode = sourceCode + "\ntechnique " + techniqueName + techniqueCode;
    }

    private string sourceCode;
    public string SourceCode { get { return sourceCode; } }
}

[ContentImporter(".psh", DefaultProcessor = "PSProcessor", DisplayName = "Pixel Shader Importer")]
class PSImporter : ContentImporter<PSSourceCode>
{
    public override PSSourceCode Import(string filename, 
        ContentImporterContext context)
    {
        string sourceCode = System.IO.File.ReadAllText(filename);
        return new PSSourceCode(sourceCode, System.IO.Path.GetFileNameWithoutExtension(filename));
    }
}