How to add config transformations for a custom config file in Visual Studio?

Visual Studio transforms only web.config files by default.

If you need custom config file with transformation for DEV, UAT, PROD, etc environments, then try to

  1. Use custom extensions for Visual Studio like SlowCheetah – XML Transforms for Config transformation preview functionality.
  2. Add for the project from Nuget SlowCheetah to provide build in transformation.

A little bit details:

Add VS Extension SlowCheetah from Extensions and Updates
Screen of Extensions and Updates

Right click on your myconfig.config and choose add transorm:
Screen of Extensions and Updates

Inside each defined configurations insert your own transormation rulles like that:

<services xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <service name="WebApplication1.Services.Service2" xdt:Transform="Replace" xdt:Locator="Match(name)" >
    <endpoint address="http://localhost:57939/Services/DebugService" behaviorConfiguration="WebApplication1.Services.Service2AspNetAjaxBehavior"
      binding="webHttpBinding" contract="WebApplication1.Services.Service2" />
  </service>
</services>

Hope it was helpful

Leave a Comment