语言 [ C#,JAVA,JS,TYPESCRIPT,DART]    后端 [ABP框架,ASP.NET MVC, Web API, SignalR, EF]    前端 [Angular]    APP [Flutter,Android]    QQ 894613921

dotnet cli

前言


dotnet cli (Command-Line Interface) .net 源代码和二进制文件管理工具。需要安装 .NET Core SDK。

终端执行 dotnet --info
可以打印出有关 .NET Core 安装和计算机环境的详细信息。

常用命令简单介绍


dotnet new

根据指定模板创建新项目,配置文件,解决方案

dotnet new -l|--list

可以列出包含指定名称的模板。(TODO:关于dotnet core项目模板留一个坑)
dotnet new -l

选项 -lang|--language

指定创建模板使用语言。接受的语言因模板而已,详情见 dotnet new -l 中的Language列。默认语言是C#。

选项 -n|name <OUTPUT_NAME>

按指定名称创建。如果未指定这个选项则使用当前目录为名称。

选项 --no-https

指定项目不需要https。

例:

当前文件夹为名创建解决方案

dotnet new sln

按指定模板创建项目,默认都采用C#

  • 创建 ASP.NET CORE的空白项目
    dotnet new web -n iLearn.Web
  • 创建MVC项目
    dotnet new mvc -n iLearn.Mvc
  • 创建Web API项目
    dotnet new webapi -n iLearn.WebApi
  • 创建控制台项目
    dotnet new console -n iLearn.Cli

dotnet sln

可以便捷的在解决方案文件中添加,删除和罗列出项目.

  • 向指定的解决方案中加入项目
    dotnet sln iLearn.sln add iLearn.Web/iLearn.Web.csproj
  • 将指定项目重解决方案中移除
    dotnet sln iLearn.sln remove iLearn.Web/iLearn.Web.csproj
  • 罗列出解决方案中的项目
    dotnet sln iLearn.sln list
    也可以使用通配符方式一次性的添加或移除
    dotnet sln iLearn.sln add */*.csproj

dotnet restore

恢复项目的依赖项和工具,该命令受Nuget.Config中某些设置影响。
大多数情况下不需要执行这个命令,因为以下命令会隐式运行dotnet restore。

dotnet new
dotnet build
dotnet build-server
dotnet run
dotnet test
dotnet publish
dotnet pack

dotnet build

将项目及依赖项生成一组二进制文件。包含

可执行的文件(扩展名为.dll)
用于调试的文件(扩展名.pdb)
记录程序依赖项的配置文件(扩展名.deps.json)
用于指定应用程序共享运行时其他版本的.runtimeconfig.json
项目引用或其他依赖的NuGet包

选项 -c|--configuration {Debug|Release}

定义生成配置,默认为Debug。

选项 -r|--runtime <RUNTIME_IDENTIFIRE>

指定目标运行时。查看.NET Core 运行时标识符号

dotnet run

可直接运行源代码命令。

选项 -c|--configuration {Debug|Release}

定义生成配置,默认为Debug。

选项 -p|--project

按指定路径的项目去运行。默认为当前目录。
dotnet run -p iLearn.Web/iLearn.Web.csproj

选项 -r|--runtime <RUNTIME_IDENTIFIRE>

指定目标运行时。查看.NET Core 运行时标识符号

dotnet clean

清理生成的输出。

dotnet publish

读取project文件,将应用程序及依赖项生成并打包到文件,用于部署。

选项 -o|--output <OUTPUT_DIRECTORY>

打包到指定目录,如果未指定,默认打包到./bin目录下

选项 -r|--runtime <RUNTIME_IDENTIFIRE>

指定目标运行时。查看.NET Core 运行时标识符号


dotnet tool

dotnet tool install

为用户提供一种在计算机上安装 .NET Core 全局工具的方法
例如安装 abp cli : dotnet tool install -g Volo.Abp.Cli

dotnet tool uninstall

从计算机上卸载指定的全局工具
dotnet tool uninstall -g Volo.Abp.Cli

dotnet tool update

更新指定的全局工具
dotnet tool update -g Volo.Abp.Cli

dotnet tool list

罗列计算机上安装的全局工具
dotnet tool list -g

posted @ 2020-01-07 14:55  JingzhuWoo  阅读(928)  评论(0编辑  收藏  举报