Build VS .Net Solution with Resource Compiler defines?

I have a Visual C++ 2013 solution that includes some DLLs. One of these DLLs is used as a Win32 resource DLL, and as such I need a way to tell it to build with a particular #define that gets through to the Resource Compiler. I have tried the Override options, but that does not seem to work at all for this. I have about 20 languages, and two versions of many, and would rather not have to replicate a big solution with them all. 

I guess first I need to know if the DefineConstants get to the RC compiler. If not, any suggestions?

(I find the modern Microsoft options to be a lot less safe feeling than the old Delphi-style stuff. On another project I’m using C++ builder and I can’t “hard set” all my defines and compiler optimisations as I’d like. I can understand this with C++ Builder but Visual Studio would be nice to get into detail with.)

Thanks,

Matthew

Hi Matthew

You can pass options to MSBuild via the Action Inspector, Extra MSBuild Options. The options you are looking for belong to the MSBuild RC task :

http://msdn.microsoft.com/en-us/library/ee862475.aspx

So PreprocessorDefinitions would probably be what you are looking for.

Covering off all the options for the C++ compiler would be a mamoth task and one that is not really needed by most users. Typically, you would create a Release Configuration in VS that has all the options you need stored in the project file, and then FinalBuilder only needs to override things like version info and output folders.

BTW, make sure you have the Use MSBuild option checked on the action, otherwise it will use devenv, which doesn’t have the same options as msbuild.

Perfect. And just the for the person who thinks too hard about this (me, when I need this again in a few years), it isn’t clever or anything. I set out trying to work out how to specify something for the “RC Task” section, perhaps like an INI file or something. But no, you just put the line 
PreprocessorDefinitions=LANG_GERMAN=1;MATTHEW
and it is passed to the right place in the build. 

Magic stuff. Going to save hours this one in FinalBuilder.

I am significantly struggling to make this work though. The FinalBuilder part seems to be fine, but MS Build or the compiler doesn't see it. (I would indent the next part, but can't do so without indenting all?).

MSBuild Properties
Configuration="Debug"
Platform="Win32"
DefineConstants="BUILD_LANG=1"
Optimize=False
AllowUnsafeBlocks=False
PreprocessorDefinitions="BUILD_LANG=1"
ShowProgress="True"


But the #if or #ifdef in the .h of the .RC and the .c files are not picking these up. 

So far I've not worked out from Google how to really make this work, so if anyone has any pointers, I'd be most interested. Thanks!

Hi Matthew,

does this work when you run MSBUILD from the command line? (completely excluding FinalBuilder?)

-dave

And for completeness, the only way I managed to make it work was using http://stackoverflow.com/questions/15141429/ and the override.props. Fortunately FinalBuilder makes it easy to output the extra file and then call the solution appropriately.

Action.ExtraMSBuildProperties.Add(“ForceImportBeforeCppTargets=C:\dev\project\override.props”)