GithubHelp home page GithubHelp logo

andrewlock / dotnet-config2json Goto Github PK

View Code? Open in Web Editor NEW
35.0 4.0 18.0 21 KB

A simple tool to convert a web.config file to an appsettings.json file

License: Other

PowerShell 4.09% C# 95.91%

dotnet-config2json's Introduction

dotnet-config2json

AppVeyor build status

NuGet MyGet

A simple tool to convert a web.config file to an appsettings.json file.

Installation

The latest release of dotnet-config2json requires the 2.1.300 .NET Core SDK or newer. It also works with .NET Core 2.2. and .NET Core 3.1. Once installed, run this command:

dotnet tool install --global dotnet-config2json

Usage

Usage: dotnet config2json [arguments] [options]

Arguments:
  path          Path to the file or directory to migrate
  delimiter     The character in keys to replace with the section delimiter (:)
  prefix        If provided, an additional namespace to prefix on generated keys

Options:
  -?|-h|--help  Show help information

Performs basic migration of an xml .config file to
a JSON file. Uses the 'key' value as the key, and the
'value' as the value. Can optionally replace a given
character with the section marker (':').

dotnet-config2json's People

Contributors

andrewlock avatar damirarh avatar juner avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

dotnet-config2json's Issues

Null reference issue

At first I got a helpful message about unity, but when I stripped unity out of my config I was left with a generic exception so then I stripped all sections except the microsfoft ones but still got a generic exception.

It works if I strip it down to connectionstring and appsettings. Is that expected?

$ dotnet config2json Web.config
Checking 'Web.config'...
Path 'Web.config' is a file
Migrating Web.config...
None of the parsers could parse [<unity configSource="config\Unity.config" />]!
An error occurred migrating Web.config:
System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.Extensions.Configuration.ConfigFile.KeyValueParser.AddToDictionary(XElement element, Stack`1 context, SortedDictionary`2 results) in C:\projects\dotnet-config2json\src\dotnet-config2json\Parser\KeyValueParser.cs:line 146
   at Microsoft.Extensions.Configuration.ConfigFile.KeyValueParser.ParseElement(XElement element, Stack`1 context, SortedDictionary`2 results) in C:\projects\dotnet-config2json\src\dotnet-config2json\Parser\KeyValueParser.cs:line 85
   at Microsoft.Extensions.Configuration.ConfigFile.KeyValueParser.ParseElement(XElement element, Stack`1 context, SortedDictionary`2 results) in C:\projects\dotnet-config2json\src\dotnet-config2json\Parser\KeyValueParser.cs:line 104
   at Microsoft.Extensions.Configuration.ConfigFile.KeyValueParser.ParseElement(XElement element, Stack`1 context, SortedDictionary`2 results) in C:\projects\dotnet-config2json\src\dotnet-config2json\Parser\KeyValueParser.cs:line 104
   at Microsoft.Extensions.Configuration.ConfigFile.ConfigFileConfigurationProvider.ParseElement(XElement element, Stack`1 context, SortedDictionary`2 results) in C:\projects\dotnet-config2json\src\dotnet-config2json\Parser\ConfigFileConfigurationProvider.cs:line 103
   at Microsoft.Extensions.Configuration.ConfigFile.ConfigFileConfigurationProvider.Load() in C:\projects\dotnet-config2json\src\dotnet-config2json\Parser\ConfigFileConfigurationProvider.cs:line 85
   at Config2Json.FileMigrator.MigrateFile(String file) in C:\projects\dotnet-config2json\src\dotnet-config2json\FileMigrator.cs:line 53
Migration complete.

jogai@myPc C:\SRC\myProj\myProj.Web\myProj.Web
$ dotnet config2json Web.config
Checking 'Web.config'...
Path 'Web.config' is a file
Migrating Web.config...
An error occurred migrating Web.config:
System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.Extensions.Configuration.ConfigFile.KeyValueParser.AddToDictionary(XElement element, Stack`1 context, SortedDictionary`2 results) in C:\projects\dotnet-config2json\src\dotnet-config2json\Parser\KeyValueParser.cs:line 146
   at Microsoft.Extensions.Configuration.ConfigFile.KeyValueParser.ParseElement(XElement element, Stack`1 context, SortedDictionary`2 results) in C:\projects\dotnet-config2json\src\dotnet-config2json\Parser\KeyValueParser.cs:line 85
   at Microsoft.Extensions.Configuration.ConfigFile.KeyValueParser.ParseElement(XElement element, Stack`1 context, SortedDictionary`2 results) in C:\projects\dotnet-config2json\src\dotnet-config2json\Parser\KeyValueParser.cs:line 104
   at Microsoft.Extensions.Configuration.ConfigFile.KeyValueParser.ParseElement(XElement element, Stack`1 context, SortedDictionary`2 results) in C:\projects\dotnet-config2json\src\dotnet-config2json\Parser\KeyValueParser.cs:line 104
   at Microsoft.Extensions.Configuration.ConfigFile.ConfigFileConfigurationProvider.ParseElement(XElement element, Stack`1 context, SortedDictionary`2 results) in C:\projects\dotnet-config2json\src\dotnet-config2json\Parser\ConfigFileConfigurationProvider.cs:line 103
   at Microsoft.Extensions.Configuration.ConfigFile.ConfigFileConfigurationProvider.Load() in C:\projects\dotnet-config2json\src\dotnet-config2json\Parser\ConfigFileConfigurationProvider.cs:line 85
   at Config2Json.FileMigrator.MigrateFile(String file) in C:\projects\dotnet-config2json\src\dotnet-config2json\FileMigrator.cs:line 53
Migration complete.

jogai@myPc C:\SRC\myProj\myProj.Web\myProj.Web
$ dotnet config2json Web.config
Checking 'Web.config'...
Path 'Web.config' is a file
Migrating Web.config...
An error occurred migrating Web.config:
System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.Extensions.Configuration.ConfigFile.KeyValueParser.AddToDictionary(XElement element, Stack`1 context, SortedDictionary`2 results) in C:\projects\dotnet-config2json\src\dotnet-config2json\Parser\KeyValueParser.cs:line 146
   at Microsoft.Extensions.Configuration.ConfigFile.KeyValueParser.ParseElement(XElement element, Stack`1 context, SortedDictionary`2 results) in C:\projects\dotnet-config2json\src\dotnet-config2json\Parser\KeyValueParser.cs:line 85
   at Microsoft.Extensions.Configuration.ConfigFile.KeyValueParser.ParseElement(XElement element, Stack`1 context, SortedDictionary`2 results) in C:\projects\dotnet-config2json\src\dotnet-config2json\Parser\KeyValueParser.cs:line 104
   at Microsoft.Extensions.Configuration.ConfigFile.KeyValueParser.ParseElement(XElement element, Stack`1 context, SortedDictionary`2 results) in C:\projects\dotnet-config2json\src\dotnet-config2json\Parser\KeyValueParser.cs:line 104
   at Microsoft.Extensions.Configuration.ConfigFile.ConfigFileConfigurationProvider.ParseElement(XElement element, Stack`1 context, SortedDictionary`2 results) in C:\projects\dotnet-config2json\src\dotnet-config2json\Parser\ConfigFileConfigurationProvider.cs:line 103
   at Microsoft.Extensions.Configuration.ConfigFile.ConfigFileConfigurationProvider.Load() in C:\projects\dotnet-config2json\src\dotnet-config2json\Parser\ConfigFileConfigurationProvider.cs:line 85
   at Config2Json.FileMigrator.MigrateFile(String file) in C:\projects\dotnet-config2json\src\dotnet-config2json\FileMigrator.cs:line 53
Migration complete.

An item with the same key already exists

I get the following error.

System.ArgumentException: An item with the same key has already been added. Key: appSettings
at System.Collections.Generic.Dictionary2.TryInsert(TKey key, TValue value, InsertionBehavior behavior) at System.Collections.Generic.Dictionary2.Add(TKey key, TValue value)
at Microsoft.Extensions.Configuration.Memory.MemoryConfigurationProvider..ctor(MemoryConfigurationSource source)
at Microsoft.Extensions.Configuration.Memory.MemoryConfigurationSource.Build(IConfigurationBuilder builder)
at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build()
at Config2Json.FileMigrator.MigrateFile(String file) in C:\projects\dotnet-config2json\src\dotnet-config2json\FileMigrator.cs:line 65

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.