Skip to content

Latest commit

 

History

History
40 lines (24 loc) · 1.8 KB

README.md

File metadata and controls

40 lines (24 loc) · 1.8 KB

varsub

varsub is tool for variable substitutions in JSON files. It was created as a replacement for the FileTransform task for DevOps, because it could not process multiple ZIP files at once.

Installation

varsub is implemented as a .NET Global Tool, so its installation is quite simple:

dotnet tool install -g Kros.VariableSubstitution

To update it to the latest version, if it was installed previously, use:

dotnet tool update -g Kros.VariableSubstitution

How to use it

varsub -w d:\Projects\artifacts -j **/appsettings.json

Parameters

--workingDirectory, -w: Working directory.

--zipFilesOrDirectories, -f: Glob pattern to search a list of files or directories.

--jsonTargetFiles, -j: Glob pattern to search the target Json files.

--tempDirectory, -t: Path to temp directory.

--variables, -v: Variables. (var1=value1 var2=value2)

This tool processes all ZIP files that match the --zipFilesOrDirectories pattern in working directory. Multiple glob patterns are allowed (-f *pattern.zip -f **/anotherPattern.zip ...). Processes all files that match the --jsonTargetFiles pattern. By default, it takes variables from environment variables. It tries to find the corresponding property in the JSON object for these variables. If a match is found, it will replace it.

The --variables parameter can be used mainly for testing purposes, with which it is possible to define variables and their values (--variables var1=value1 --variables var2=value2 ...).

⚠ It is not possible to add a new property to a JSON object or a new record to a JSON field using this tool. It only allows the replacement of existing properties.