I wanted to do some extra stuff when compiling a Visual Studio project but only when I was working in Debug mode. You can easily do this by adding the configuration name to the post-build script and check it in there to see if it should run. You can pass the configuration name with $(ConfigurationName).
A sample:
if $(ConfigurationName) == Debug (
copy "$(TargetDir)test.dll" "c:\testrun\" /y
)