How do you define a Makefile style variable in a solution to be used across multiple projects (VS 2008)?

I am working in a Visual Studio 2008 solution with several C # projects and some C ++ projects and want to use post build events to execute some 3rd party vendor command line tools. These post-build events are required in several projects.

I can hard-code the path names and other files needed on the command line, but I would prefer something more flexible. Maybe:

$ (ToolsDir) \ $ (PackageBuilder) $ (ThirdPartyDllFolder) $ (SharedOutputFolder)

When I was developing for UNIX and using makefiles to do the build, I was able to define a variable in a high level makefile and inherit it using child makefiles. This way I could output all weekend to a specific location, or search in a specific location for a library, etc.

Is there an equivalent thing that can be done with Visual Studio solutions so that I can define something like an environment variable and then refer to it in a post-build event at the project level?

EDIT: I'm using windows environment variables right now, but would prefer something that didn't require installation outside of downloading the code and generating it.

+1


a source to share


2 answers


Have you considered environment variables on Windows? I know these are not exactly the same, but you can install them using a batch file and follow this post-compiler.



+1


a source


I had a similar problem a while ago. My first "solution" was to create a tool that was built and run when the developer got the first "get" from the repository. It was ugly and was another step - but only once.

I gave up on this and now we have another method. We put the third part tools into an svn repository (other than our source) and require a specific hierarchy and name for where that repository lives in relation to the root of our codebase. This way we can use relative paths with confidence in our post-build stages or other parts.



I agree that this is a bit of a weakness in MS build tools.

+1


a source







All Articles