Modified to work with VS2012 (could probably work with other versions,
but need them installed to compile against their assemblies)
Also added cleanup logic and tweaked the granularity at which the vars
are updated to be on configuration changes rather than on build (when
using these macros for OutputPath this lateness confused Visual Studio)