views:

58

answers:

3

Our product contains a bunch of modules spread out over several visual studio solutions and uses C++ and C#. I'd like to define a product name and use it as part of default folder locations, registry keys, etc.

What is the simplest way to define this product name in one place? And if I have to use a different approach for C++ and C#, what would you advise for each of them?

A: 

According to Microsoft, it looks like you should be able to put everything into 1 solution, then have sub-solutions within that:

MSDN Structuring Solutions and Projects

EDIT: Article is for Team Foundation Server, so I guess you can't necessarily do this.

smoore
No Team Foundation here. We are using a multi-solution approach.
Martin
Didn't read through the whole article, but I assume it is just talking about having different "project" types within the one solution. If this is the case, then you can do this in VS Professional. Once you do that, you can usually use the "$(SolutionName)" in the project settings to grab the name of the solution, which you could then use as the product name
Grant Peters
A: 

I can't necessarily say what would be the simplest, but I do know what we've done here thats worked out reasonably well.

For C++ projects we have a common header file that is included - it has #defines for all the common non-localizable strings used by the applications (ProductNames, CompanyName, Version, Registry Keys, File Prefix/Extensions, etc). And the individual project just include and reference those defines. I used defines specifically rather than constants because that way i could also change all the Version resources to reference those same defines without any issues (In fact, all the project's .rc files include the same version.rc to guarantee uniformity).

For our C# projects i use a simple class to contain constants that are referenced by the c# projects.

Unfortunately this leaves two places for maintenance but at this point it works well enough and we've had so little need to update those Defines/Constants that we haven't needed to come up with a more integrated approach yet.

I'd be interested in hearing other approaches...

Ruddy
A: 

This is the solution I will try to implement:

C++ and C# will each have their own function to get the product name, and those functions will have a default name.

The default name can be overwritten by the environment variable "PRODUCTNAME", this way we can easily build our software under different names by only modifying that environment variable.

[Edit] My C++ solution compiles a DLL which contains (among others) the function:
GetProductName(char* pName, int iSize);
so product name is now only defined in one place.

Martin
Just to be more explicit: the C# projects use the C++ DLL to get the product name.
Martin