Fan.Demo.Template
1.0.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet new install Fan.Demo.Template@1.0.0
This package contains a .NET Template Package you can call from the shell/command line.
// 通过命令行创建 core api项目
dotnet new webapi
// 通过自定义命令行创建自己的项目
dotnet new 我是模板名称 -n HelloBlog
├── temple // 用来存放所有的模板
│ ├── BlogCoreTemple // BlogCore模板全部内容
│ │ ├── content // 存放Code 项目代码,可直接运行
│ │ │ ├── Blog.Core
│ │ │ ├── .
│ │ │ ├── .
│ │ │ ├── .
│ │ │ ├── Blog.Core.Services
│ │ │ └── Blog.Core.sln
│ │ │
│ │ ├── license // 存放版本许可信息,如果不添加,后边会警告,文章后边会提到
│ │ │ └── license.txt
│ │ │
│ │ └── 其他待定 // 这里文章后边会打包的时候用到
│ │
│ └── DDDTemple // DDD模板信息
{
"$schema": "http://json.schemastore.org/template",//template.json 文件的 JSON 架构,可以不要该键值对
"author": "lao zhang", //必填!模板创建者
"classifications": [ "Web/WebAPI" ], //必填,这个对应模板的Tags,其他的比如 [ "Common", "Console" ],
"name": "Blog.Core Dotnet", //必填,这个是模板名,比如ASP.NET Core Web API
"identity": "Blog.Core.Template", //可选,模板的唯一名称
"shortName": "blogcoretpl", //必填,这个对应模板的短名称,比如webapi
"tags": {
"language": "C#" ,
"type":"project"
},
"sourceName": "Blog.Core", // 可选,要替换的名字,这个就是模板的项目名,以后新建的时候,会把这个名字替换成其他,比如HelloBlog(警告!这里不要写一些专用词汇,比如app呀,net呀,core之类的)
"preferNameDirectory": true // 可选,添加目录
}
// 使用文件分发模板,
// 注意文件路径:content文件夹的上一级,可以对比上边的截图中的文件夹结构
dotnet new -i D:\myTpl\temple\BlogCoreTemple
dotnet new -u D:\myTpl\temple\BlogCoreTemple
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>Blog.Core.Webapi.Template</id>// nuget包标识,在 nuget.org 或包驻留的任意库中必须是唯一的
<version>1.0.0</version>// 遵循 major.minor.patch 模式的包版本。
<description>
Creates a blog core webapi app.// 用于 UI 显示的包的详细说明。
</description>
<authors>Lao zhang</authors>// 包创建者的逗号分隔列表,与 nuget.org 上的配置文件名称一致
<packageTypes>
<packageType name="Template" />// 包类型
</packageTypes>
<license type="file">license\license.txt</license>// 上文提到的许可证信息
</metadata>
</package>
下载Nuget.exe
https://www.nuget.org/downloads
生成Nupkg包
// 执行打包操作,文件地址就是 nuspec 范本地址
nuget pack D:\myTpl\temple\BlogCoreTemple\Blog.Core.Webapi.Template.nuspec
This package has 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.