Pass MGCB /define param from .csproj


Is it possible to pass the /define parameter from the .csproj file?

I have multiple projects pointing to the same content file but I need different inclusions depending on platform. I figured the easiest way is to have preprocessor macros inside the content file and have different projects pass the preprocessor param.

If this is not possible - what’s the most elegant way of having multiple platforms share 95% of the content and have the remaining 5% separated? One common content file + an additional one per platform?


You would have to customize the .target file to allow you to pass whatever you want:

Like different content files for one platform vs another?

This is a feature we really want to get into the Pipeline tool directly, but I’ve not had time to implement.

That is a reasonable option and how you would have done it in XNA if you didn’t want to hand modify the .contentproject flle.

Yes - mostly for shaders since they tend to be quite different on different platforms. This feature would be really cool.

I don’t really like the idea of having multiple content files so I’ll copy the .target file, edit it and reference it locally. I’ll probably just add:


That should cover my use-case without introducing many custom params.

Thanks for the tips!

I just tried tinkering with mgcb.exe and it seems there’s no /define option although the doc page mentions it. I installed the latest version (3.5) but still no luck. What am I missing?

Note you can use #ifdef within shaders themselves. Look to see how we do it in the stock effects:

Notice the #include "Macros.fxh" which is where all the helpers for tweaking shaders based on the target platform.

Hum… that command does look missing from the command line parser:

The intent was for it to push a named value on to the property collection here:

Sort of like the $set preprocessor command does:

Don’t know how this got documented, but the implementation is missing.