Giter Site home page Giter Site logo

bubdm / fatantelope Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cameronwills/fatantelope

0.0 0.0 0.0 190 KB

A tool for comparing .NET .config files and generating a config transform (Microsoft Xml Document Transform).

License: Other

C# 100.00%

fatantelope's Introduction

FatAntelope

A tool for comparing two .config files and generating an XDT transform (Microsoft XML Document Transform). Useful for creating config transforms for existing production web.config or app.config files.

Build status Release NuGet Stars

How it works

FatAntelope parses the two config (xml) files into two trees and performs an unordered diff / comparison to identify nodes that have been updated, inserted or deleted, and then generates a XDT transform from these differences.

The XML diff / comparison algorithm is a C# port of the 'XDiff' algorithm described here: http://pages.cs.wisc.edu/~yuanwang/xdiff.html

Try It

A demonstration is setup here: fatantelopetester.apphb.com

Download

Download the command-line tool in releases

Usage

Following build, you can use reference the FatAntelope.Core library directly or otherwise run the command-line tool

Command Line Syntax

FatAntelope source-file target-file output-file [transformed-file]

   source-file : (input) original config file path.  E.g. the development web.config

   target-file : (input) final config file path.  E.g. the production web.config

   output-file : (output) file path to save the generated patch.  E.g. web.release.config

   transformed-file : (output, optional) file path to save the result from applying the output-file to the source-file.

Example

FatAntelope app.config prod_app.config app.release.config

Source File (app.config):

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
  </startup>
  <connectionStrings>
    <add name="Users" connectionString="Data Source=127.0.0.1;initial catalog=UserDB;user id=myUser;password=myPassword" providerName="System.Data.EntityClient" />
    <add name="Posts" connectionString="Data Source=127.0.0.1;initial catalog=PostDB;user id=myUser;password=myPassword" providerName="System.Data.EntityClient" />
  </connectionStrings>
  <appSettings>
    <add key="MyUrl" value="http://localhost:50634" />
    <add key="MyService.Api" value="http://localhost:10424" />
  </appSettings>
</configuration>

Target File (prod_app.config) :

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
  </startup>
  <connectionStrings>
    <add name="Users" connectionString="Data Source=203.1.1.1;initial catalog=UserDB;user id=myUser;password=myPassword" providerName="System.Data.EntityClient" />
    <add name="Posts" connectionString="Data Source=203.1.1.1;initial catalog=PostDB;user id=myUser;password=myPassword" providerName="System.Data.EntityClient" />
  </connectionStrings>
  <appSettings>
    <add key="MyUrl" value="http://MyAmazingWebsite.com" />
    <add key="MyService.Api" value="http://MyAmazingWebsite.com/Api" />
  </appSettings>
</configuration>

Patch File (app.release.config) :

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <connectionStrings>
    <add name="Users" xdt:Locator="Match(name)" connectionString="Data Source=203.1.1.1;initial catalog=UserDB;user id=myUser;password=myPassword" xdt:Transform="SetAttributes(connectionString)" />
    <add name="Posts" xdt:Locator="Match(name)" connectionString="Data Source=203.1.1.1;initial catalog=PostDB;user id=myUser;password=myPassword" xdt:Transform="SetAttributes(connectionString)" />
  </connectionStrings>
  <appSettings>
    <add key="MyUrl" xdt:Locator="Match(key)" value="http://MyAmazingWebsite.com" xdt:Transform="SetAttributes(value)" />
    <add key="MyService.Api" xdt:Locator="Match(key)" value="http://MyAmazingWebsite.com/Api" xdt:Transform="SetAttributes(value)" />
  </appSettings>
</configuration>

Caveats

  • The generated XDT transform may not have the most optimal values for the xdt:Locator and xdt:Transform attributes. I recommend only using this output as a starting-point for your transforms.

  • The XML comparison algorithm used (XDiff) does an unordered comparison of XML nodes, so changes to child elements' position within the same parent will be ignored.

Why 'FatAntelope'

A fat antelope for a slow cheetah

FatAntelope

fatantelope's People

Contributors

cameronwills avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.