记: 创建nuget模板

创建Nuget模板

目的

这样做,当然是为了以后建立同样的项目时,方便一点,统一目录结构

过程

  1. 当然首先需要一个能编译通过的项目,我建的是解决方案,同理

  2. 在解决方案目录下建立配置文件,目录结构如图:

    目录结构

  3. 配置文件template.json内容

    {
        "$schema": "http://json.schemastore.org/template",
        "author": "author",
        "classifications": ["Solution"],
        "name": "Leaf templates: MicroService Module",// 自定义
        "identity": "Leaf.Module",// 自定义定义
        "shortName": "leafmodule",// 自定义
        "tags": {
            "language": "C#",
            "type": "project"
        },
        "sourceName": "Leaf.AccountModule",// 自定义
        "preferNameDirectory": true,
        "symbols": {
            "projectName": {
                "type": "parameter", // 定义一个参数
                "defaultValue": "Leaf",
                "replaces": "Leaf", // 定义需要替换的字符串,在项目中,所有匹配的字符串(Leaf)都会替换为设置的参数或者默认值
                "fileRename": "Leaf", // 定义需要替换的文件名,同上
                "description": "your project name"
            },
            "moduleName": {
                "type": "parameter",
                "isRequired": true,
                "defaultValue": "Deafult",
                "replaces": "Account",
                "fileRename": "Account",
                "description": "your moulde name"
            }
        },
    }
    
  4. 其它的,参照官网的例子就能创建成功

参考

github

posted @ 2020-01-11 17:16  Maple512  阅读(414)  评论(0编辑  收藏  举报