XNAContentCode is a utility
meant to be called during the pre build event of what ever project you want it to
process. What it does is parse the content project *.csproj file, and generate C# code that
mirrors whatever game assets may be included in your GSE project. This allows you
the ability to, instead of using strings, to use C# code to reference your game
assets. Think of the VS.net Resources system, where you would type Resources.YourCustomResourceName,
only XNAContentCode generates static classes (and nested classes if needed) and
static const members that you can write code against instead of using strings.
For example say you had added a few game assets to your GSE project. After XNAContentCode
is run you can reference those assets by typing Content.SomeGameAsset. This also
has the advantage of giving you compile errors if you move or rename a game asset.
Where as normally you would use a string in your code to access a game asset if
you moved or renamed a game asset you would not know weather or not your game would
work until run time when you ran the game, with XNAContentCode you can get feedback
in the form of compile errors at design time.
XNAContentCode also allows you to specify a header and footer code files to pre-pend
and append the code that XNAContentCode generates with your own custom wrapper code
or comments. A typical usage of XNAContentCode is to add something like this to
the pre build event of the desired project
"$(SolutionDir)XNAContentCode\bin\Debug\XNAContentCode.exe" "$(ProjectPath)"
"$(ProjectDir)Content.cs" "$(ProjectDir)Code\ContentHeader.txt" "$(ProjectDir)Code\ContentFooter.txt"
XNAContentCode.exe name of project Dest code file header file footer file
------------------ --------------- -------------- ------------- -------------
XNAContentCode.exe SomePrj.csproj Content.cs header.txt footer.txt
NOTE: Header and footer files are optional arguments.
Downloads