I’m working on a project that I will release as open source, but it will have to contain some values (BASS audio library freeware regkey, url for update server, etc.) that I only want to be compiled into the source when compiling it for a binary release for those people that just want to use the application and do not care about the source. Basically, I want to prevent people who use the source code from using my reg key (they can get their own for free) or having their version contact my update server since versions will be different.
So, what’s the best way to make something that will be compiled into the code and used if the file exists, but I could then exclude from source control and it would just use defaults or disable compilation of certain sections if that file does not exist?
You could edit the project file to conditionally include either one file or another based on the build type. I don’t have a sample to hand, but it shouldn’t be too hard to do. Something like:
I would try to structure the “library” part separately from the “application” part, and always make the library part take the relevant parameters in its configuration. That way anyone just wanting to use the library should be able to use a “release” DLL – it’s only the application which needs the extra file before it’ll work.
EDIT: It’s entirely possible that the same approach will work with
app.configif you want to include the values in a config file instead.