How to run Visual Studio post-build events for debug build only
FYI, you do not need to use goto. The shell IF command can be used with round brackets:
if $(ConfigurationName) == Debug (
copy "$(TargetDir)myapp.dll" "c:\delivery\bin" /y
copy "$(TargetDir)myapp.dll.config" "c:\delivery\bin" /y
) ELSE (
echo "why, Microsoft, why".
)
Pre- and Post-Build Events run as a batch script. You can do a conditional statement on $(ConfigurationName)
.
For instance
if $(ConfigurationName) == Debug xcopy something somewhere
Add your post build event like normal. Then save your project, open it in Notepad (or your favorite editor), and add condition to the PostBuildEvent property group. Here's an example:
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<PostBuildEvent>start gpedit</PostBuildEvent>
</PropertyGroup>