Microsoft might have inadvertedly shed some light on this subject, as they have recently made available a prerelease of an API to perform these XDT transformations which is available through NuGet here: https://nuget.org/packages/Microsoft.Web.Xdt.
Knowing this, I’ve decided to explore this new API and put it to good use. I've created a CodeActivity to use this API and integrate the XDT transformations in my build process. Another alternative (I was previously using) is to rely on an external tool to do the transformations for you and invoke that tool from within your build process (see the Config Transformation Tool here: http://ctt.codeplex.com ).
So here’s a code activity to do just that: run XDT on your web.config depending on the project configuration being built: