The LZMA Content Manager loads content for an XNA game either from individually LZMA-compressed content files or from a LZMA archive containing multiple content files. In a real-world application, LZMA compression has trimmed the game's size to about 66%
of the size achieved by XNA's built-in content compression without any noticeable impact on loading performance.
Compressing your Content
To compress you game content files, it is important to first disable XNA's built-in content compression. Otherwise, the LZMA algorithm has shown to not provide any significant gains.
After your game is built, the Nuclex ContentCompressor can be run on your game assets. To compress content files individually, navigate to your game's output directory and use the following command line:
The tool automatically works recursively. If you want it to delete the original files after it has compressed them, append the
parameter. Don't worry, the *.xnb files are rebuilt when you compile your project, but if you've got them in compressed form, you don't actually need them in uncompressed form, so the
parameter is useful when you do your final build before shipping.
If you want to compress your content files into one big archive, invoke the ContentCompressor like this:
\path\to\Nuclex.ContentCompressor --package MyPackage.npk *.xnb
As before, the tool will work recursively and you can use the
parameter to delete the original files after compression.
In all cases, instead of *.xnb
, you can also specify a text file containing a list of files to process by appending an
to the file name like this:
\path\to\Nuclex.ContentCompressor --package MyPackage.npk @FilesToCompress.txt
is almost a drop-in-replacement for the normal
If you compressed your content files individually, just construct it normally:
LzmaContentManager contentManager = new LzmaContentManager(Game.Services);
If you compressed your content files into a single package, specify the package the content manager should open:
LzmaContentManager contentManager = new LzmaContentManager(
You can then use the LZMA Content Manager like you would use the normal content manager. For content nested in subdirectories, the package will use the '/' (forward slash, not backward slash) character to separate directory levels. This is because the
forward slash works well on windows, but if Mono.Xna or a similar project ever manages to reach a usable state, the forward slash will work everywhere and doesn't need manual