+2  A: 

You can transform a config file by using the same objects the MSBuild task uses, bypassing MSBuild altogether. Web config transform logic is contained in the Microsoft.Web.Publishing.Tasks library.

The following code snippet comes from a simple class library, referencing the Microsoft.Web.Publishing.Tasks library (which is installed on my machine at C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\Web).

The sample loads a source document and transform, applies the transform, and writes the results to a new file.

using System;
using Microsoft.Web.Publishing.Tasks;

// ...

var xmlTarget = new XmlTransformableDocument();
xmlTarget.PreserveWhitespace = true;
xmlTarget.Load("Web.config");

var xmlTransform = new XmlTransformation("Web.Release.config");

if (xmlTransform.Apply(xmlTarget))
    xmlTarget.Save("Web.Transformed.config");
else
    Console.WriteLine("Unable to apply transform.");

With a little creativity, this simple solution could be integrated into a Visual Studio plugin, perhaps as a context menu item on the web.config file. At the very least, you can make a console utility or script out of it to generate previews.

Good luck!

kbrimington
@kbrimington this is essentially an expansion of my "Edit 2" paragraph. I feel like there is at least some need for a tool like this and I starting to put the pieces together myself. With any luck I hope to release something on the Extension Gallery in the near future. Thank you for the input!
Nathan Taylor
@Nathan: Good luck with the extension. I look forward to seeing it. The CodePlex tool works by invoking MSBuild. For a custom tool you'll likely want to use the library directly as shown. Do me a favor and add a comment when you're finished. Good luck!
kbrimington
@kbrimington I also initially thought it worked by invoking MSBuild, but after browsing the source I realized he is using the libraries you mentioned above. From the looks of it, it shouldn't be difficult at all to build a functional prototype of the extension.
Nathan Taylor
@Nathan - Nice. Thanks for the follow-up.
kbrimington