记: 创建nuget模板

Posted maple512

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了记: 创建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

以上是关于记: 创建nuget模板的主要内容,如果未能解决你的问题,请参考以下文章

如何将 xaml 模板打包成 nuget 包以供其他开发人员重用?

创建一个从在线提要中提取 NuGet 引用的 Visual Studio 项目模板

创建自己的代码片段(CodeSnippet)

在 VS 2010 项目模板中自动安装 NuGet 包

十个html5代码片段,超实用,一定要收藏

Atom编辑器折腾记_(15)JS代码片段补全(插件:javascript-snippets)