项目模板

1
2
3
4
5
6
7
8
9
10
11
12
{
"author": "iaccount@foxmail.com",
"classifications": [ "标签" ],//标签
"name": "项目模板名称",
"identity": "identity", //模板唯一标识可以使用guid
"groupIdentity": "group",//分组,可有可无
"shortName": "shortName", //使用 dotnet new <shortName> 安装模板时的名称
"tags": {
"language": "C#",
"type": "project"
},
"sourceName": "sourceName", //【修改】在使用 -n 选项时,会替换模板中项目的名字,使用项目名字,文件和文件夹,命名空间 都会在使用时替换掉"preferNameDirectory": true <br>}  

以上内容写入template.json 并存放至.template.config文件夹内

 

在项目文件夹内执行以上操作后 ,按住shift +右键点击 在在此处打开powershell窗口

接着输入以下命令
# 新建模板
# 模板安装命令:dotnet new i <path | nugetId>
# 这里因为是安装本地模板,直接使用路径(绝对和相对均可) ,.代表当前目录
dotnet new -i . 

dotnet new -l  --查看已安装的项目模板(小写L)

 #卸载项目使用

dotnet new -u D:\GitHub\DotNetCore\WindowsService

至此项目模板已经创建完成! 

------------------------------我是分隔符--------------------------------------------------------------

 

用该模板创建新的项目
使用模板,请在新建项目的目录中使用以下语句
# 这里使用 -n 和 -o 选项来分别指定新项目的名字以及输出目录
# 设定新项目的名字为“NewProject”,因为当前定位已经在 NewProject 文件夹内,所以直接用“.”,如下:
dotnet new  [TemplateName] -n  NewProject  -o .

 [TemplateName]是模板配置文件中指定的 项目模板名称。

 

 

命令:

查看版本

1
dotnet --version

查看帮助命令

1
dotnet -h

创建项目(dotnet new)

1
2
3
dotnet new -l                             --查看已安装的项目模板
dotnet new console -o ./myConsole            --通过指定模板创建项目,创建一个控制台项目
dotnet new -i identityserver4.templates      --安装项目模板

编译项目,生成二进制文件

1
dotnet build

发布项目(dotnet publish)

1
dotnet publish -o /output -c Release

清理

1
dotnet clean

运行项目,相当于F5(dotnet run)

1
2
dotnet run -c Release  --Release版本
dotnet watch run      --当代码改变时,自动编译运行,开发时使用

运行已编译项目

1
nohup dotnet xxx.dll &      (ps:必须使用exit退出终端,否则后台进程会退出)

  

dotnet 命令:

1
2
3
4
查看安装的模板:dotnet new -l
安装模板:dotnet new -i [项目模板路径]
删除模板:dotnet new -u [项目模板路径]
创建项目:dotnet new [项目模板名称] -n [解决方案名称] -o [生成项目路径]
posted @   贾咩咩  Views(105)  Comments(0Edit  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
点击右上角即可分享
微信分享提示