Here’s simple code to add to a project’s “Build Events” post-build properties:

if exist "$(ProjectDir)Web.$(ConfigurationName).config" (copy "$(ProjectDir)Web.$(ConfigurationName).config" "$(ProjectDir)Web.config")

It searches for a build-type web.config, then replaces the current web.config with the build-type web.config file. Example of a build-type web.config’s

web.Release.config
web.Debug.config

This is best if you don’t want to continually set the
<compilation debug="true"> attribute or adjust any other settings like switching database connections, setting any <appSettings> properties, etc…