Click here to Skip to main content
15,888,521 members
Articles / General Programming / Tools

Small Helper Tool for Configuration Transformations

Rate me:
Please Sign up or sign in to vote.
4.67/5 (4 votes)
21 Apr 2015CPOL2 min read 10.9K   15   5   2
Small Helper Tool for Configuration Transformations

In my daily work, I often use configuration transformations for different settings for different environments and often I need to add a new transformation for a new environment. So, I've decided to create a small tool that can automate adding new transformations to all the projects in a solution. In addition to this, I've added functionality for applying config transformations as this can be useful if you want to test the transformations from command line. Here's a short description of the tool:

TransformHelper

Small tool helping with the usage of the configuration transformations.

It has two:

  • Add - Passing solution, existing transformation and the new transformation the tool will go through all the projects in the solution and check for configuration files having the existing transformation and will add new transformation copying the files from the existing
  • Remove - Passing solution, and existing transformation the tool will go through all the projects in the solution and check for configuration files having the existing transformation and will delete them
  • Apply - Passing source file, transformation file and optional target file (if not passed, the source file content will be replaced)
  • ApplySLN - Passing solution, and existing transformation the tool will go through all the projects in the solution and apply the transformation on the original file

Usage

  • Add mode (you may not specify the mode here as the Add mode is the default behavior)
    TransformHelper.exe [-mode add] -solution C:\Work\MySolution.sln -existing Dev -new Live

    This will check all the projects in the solution for files like [fileName].Dev.config and will add the corresponding [fileName].Live.config files copying the content from the existing ones.

  • Remove mode
    TransformHelper.exe -mode remove -solution C:\Work\MySolution.sln -existing Dev 

    This will check all the projects in the solution for files like [fileName].Dev.config and will delete them and remove them from the project.

  • Apply mode
    TransformHelper.exe -mode apply -source "C:\Work\MySolution\WebProject\web.config" 
    -transformFile "C:\Work\MySolution\WebProject\web.Dev.config" -target "C:\Temp\result.web.config"

    This will apply the transformation file C:\Work\MySolution\WebProject\web.Dev.config on C:\Work\MySolution\WebProject\web.config and the result content will be saved in C:\Temp\result.web.config file.

  • ApplySLN mode
    TransformHelper.exe -mode applySLN -solution C:\Work\MySolution.sln -existing Dev

This will check all the projects in the solution for files like [fileName].Dev.config and if there are files like [fileName].config as well in the project they will be transformed using the Dev transformations.

You can find the tool on github here.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Telerik
Bulgaria Bulgaria
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionIs there any code available? Pin
techno__guru21-Apr-15 11:41
techno__guru21-Apr-15 11:41 
AnswerRe: Is there any code available? Pin
Vasil Trifonov21-Apr-15 22:05
Vasil Trifonov21-Apr-15 22:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.