proposed solution will not work when a class library with config file is referenced from another project (in my case it was Azure worker project library). It will not copy correct transformed file from obj
folder into bin\##configuration-name##
folder. To make it work with minimal changes, you need to change AfterCompile
target to BeforeCompile
:
<Target Name="BeforeCompile" Condition="exists('app.$(Configuration).config')">