Easy.Tool.MergeJson
1.0.2
dotnet add package Easy.Tool.MergeJson --version 1.0.2
NuGet\Install-Package Easy.Tool.MergeJson -Version 1.0.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Easy.Tool.MergeJson" Version="1.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Easy.Tool.MergeJson" Version="1.0.2" />
<PackageReference Include="Easy.Tool.MergeJson" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Easy.Tool.MergeJson --version 1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Easy.Tool.MergeJson, 1.0.2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Easy.Tool.MergeJson@1.0.2
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Easy.Tool.MergeJson&version=1.0.2
#tool nuget:?package=Easy.Tool.MergeJson&version=1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
自动合并json工具
只需引入该包,在生成时自动将指定的多个json文件合并,生成到项目的输出目录中 自动移除json中的注释(有些系统不支持读取带注释的json)
配置
只需要在两个地方进行配置即可 1.主Json文件中(会生成到项目的Json文件) 2.YourProject.csproj 中
秒上手
只需要对项目根目录的 appsetting*.json 添加以下json即可
// 自定义配置信息
"CustomConfigInfo": {
// 子文件目录集合
"ConfigFileFolders": [ "CustomConfig1", "CustomConfig2" ],
// 要排除的文件名集合
"ExcludeSubFiles": [ "json2.json" ]
}
设置所有需要参与合并的Json文件
- 在"JsonItems"属性中包含你可能会参与合并的所有Json文件
- 默认导入当前项目所有json文件,排除生成(bin\obj)文件夹中的文件
<ItemGroup>
<JsonItems Include="**\*.json" Exclude="$(BaseOutputPath)**\*;$(BaseIntermediateOutputPath)**\*;" />
</ItemGroup>
自定义配置帮助
<ItemGroup>
<JsonItems Remove="**\*" />
<JsonItems Include="*.json" Exclude="a.json" />
<JsonItems Include="**\*.json" Exclude="**\a*.json" />
<JsonItems Include="e:\**\*.json" />
</ItemGroup>
设置主要Json文件
注:如果主json是在工作目录中,合并后的文件也会在输出目录的相对位置,否者就直接输出到输出文件中
- 在"MainJsonItems"属性中包含你想要生成到项目Json文件
- 主Json寻子Json规则
- 子json被包含在"JsonItems"中
- 主json中存在"CustomConfigInfo.ConfigFileFolders"节点(数组类型),存放子json目录路径
- 主json中"CustomConfigInfo.ExcludeSubFiles"节点,存放排除的子json文件名,这里面的json都不会被合并
- 默认项目根目录中的appsettings前缀的Json文件
- 默认子Json目录节点"CustomConfigInfo.ConfigFileFolders"
- 默认排除子文件节点"CustomConfigInfo.ExcludeSubFiles"
<ItemGroup>
<MainJsonItems Include="appsettings*.json" />
</ItemGroup>
每一个主json文件中需要有以下节点,以下节点名称时可以自定义的
// 自定义配置信息
"CustomConfigInfo": {
// 子文件目录集合
"ConfigFileFolders": [ "CustomConfig1", "CustomConfig2" ],
// 要排除的文件名集合
"ExcludeSubFiles": [ "json2.json" ]
}
自定义配置帮助
<ItemGroup>
<MainJsonItems Include="CusuomConfig\config.json" />
<MainJsonItems Update="包含的文件">
<SubDirectoryNode>CustomConfigInfo.ConfigFileFolders</SubDirectoryNode>
<ExcludeSubFilesNode>CustomConfigInfo.ExcludeSubFiles</ExcludeSubFilesNode>
</MainJsonItems>
</ItemGroup>
设置是否生成合并日志
- 在"SaveMergeLog"属性中写入true/false即可
- 生成的合并日志保存在你项目输出目录的"mergeLogs"文件夹中
- 默认 false,不会生成合并日志
<PropertyGroup>
<SaveMergeLog>false</SaveMergeLog>
</PropertyGroup>
基本概念
? 通配符匹配单个字符。
* 通配符匹配零个或多个字符。
** 通配符序列匹配部分路径。
更新日志
1.0.0
- 发布第一个正式版
1.0.1-beta1
- 修复包含子json文件夹路径是盘符根路径(e:)引发的异常
1.0.1-beta2
- 处理获取文件路径问题
1.0.1
- 无功能性更新,统一版本
1.0.2
- 修改工具程序集不生成到项目中的方式
- 修改readme文档格式
There are no supported framework assets in this package.
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
1.0.2 | 544 | 6/25/2022 |
1.0.1 | 464 | 5/24/2022 |
1.0.1-beta2 | 251 | 5/5/2022 |
1.0.1-beta1 | 238 | 5/5/2022 |
1.0.0 | 519 | 5/5/2022 |
1.0.0-beta9 | 233 | 5/1/2022 |
1.0.0-beta8 | 238 | 4/27/2022 |
1.0.0-beta7 | 229 | 4/27/2022 |
1.0.0-beta6 | 228 | 4/27/2022 |
1.0.0-beta5 | 240 | 4/25/2022 |
1.0.0-beta4 | 233 | 4/25/2022 |