When you’re working automated builds and automated releases, you frequently need to edit configuration files like app.config, web.config, and appsettings.json. Well, I wrote a command line utility to do this and I figured I’d share. I’ve got a version that is an .exe that can be used on a Windows build agent and I’ve got a version that’s written with .NET Core and can run cross-platform. Both of them have the same commands.
Here are the commands:
getappsetting:
gets a value from <appSettings> in app.config or web.config
setappsetting:
sets a value in <appSettings> in app.config or web.config
replacetoken:
does a string replace in a file and replaces all occurences of a token (example: %%CONNECTIONSTRING%%) with an actual value
getconnectionstring:
gets a connection string value from app.config or web.config
setconnectionstring:
sets a connection string value in app.config or web.config
setjsonvalue:
sets a value in a json file such as appsettings.json
setxmlattribute:
locates an element in an XML file and sets an attribute value on that element
Here are the downloads:
Source code
EXE version for Windows
Cross-platform Binaries for .NET Core
I hope that these are helpful.
-Ben
— Want to do cross-platform or Azure DevOps with ASP.NET Core and TFS? Need some help automatically deploying Entity Framework or Entity Framework Core migrations from your TFS Builds and TFS Releases? Not quite sure where to start? We can help. Drop us a line at info@benday.com.
Leave a Reply