Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
【原文发表地址】Exploring the new .NET "dotnet" Command Line Interface (CLI)
【原文发表时间】December 24, '15
我从来不太喜欢ASP.NET 5上整个的“dnvm”和“dnu”还有“dnx”的命令行的东西。存在的就是合理的,他们过去是,并且一直是重要的步骤,对于学习过程是有组织地并且是很有帮助的。
我的想法一直是:当一个新人坐在座位上开始学习node, python, ruby, golang 或者其它任何东西时,对于绝大多数人来说,按照他们的经验就应该如此。使用.NET应当被看做是一件简单的不能再简单的事了。
下面只是一段伪代码,不用花太多时间去看。
apt-get install mylang #where mylang is some language/runtime
#write or generate a foo.fb hello world program
mylang foo #compiles and runs foo
我认为学习并且使用.NET 的伙伴们应该在Go或者Ruby上有相同的经验。
· 容易获得-在每个平台上获得.NET是非常容易的。
o 我们即将在https://get.asp.net/ 上开始做,并且会单独做 .NET Core,我确信。
· 很容易写Hello World – 在这非常容易创建并开发一个基本的应用程序。
o 你可以做“dotnet new”并且开始写
简单代码。也许有一天会更多呢?
· 易编译易运行
o 只需要“dotnet”,它就可以编译和执行
· 真正的.NET
o 快速,可扩展,本地速度快,可靠
我一直在https://github.com/dotnet/cli上探索(在允许的情况下尽可能早的)关于明年将要发布的版本的相关的工作。
重要提示: 这个工具链独立于DNX-based .NET Core + ASP.NET 5 RC bits。如果你正在寻找.NET Core + ASP.NET 5 RC bits, 你可以在https://get.asp.net/ 上找到相关介绍。
一旦我安装了“dotnet”, 我就可以做下面的事情了:
>dotnet new
>dotnet restore
>dotnet run
想象着和我一块儿,当你把这个和在Mac, Windows, and Linux上运行的免费Visual Studio代码比较时,那么你已经获得了一个非常精彩的故事。开源的.NET 代码可以很容易的在很多地方运行。
下面是一段比较长的的代码,只要在顶部输入“dotnet”,就可以得到很多能用的东西。
C:\Users\Scott\Desktop\fabulous>dotnet
.NET Command Line Interface
Usage: dotnet [common-options] [command] [arguments]
Arguments:
[command] The command to execute
[arguments] Arguments to pass to the command
Common Options (passed before the command):
-v|--verbose Enable verbose output
Common Commands:
new Initialize a basic .NET project
restore Restore dependencies specified in the .NET project
compile Compiles a .NET project
publish Publishes a .NET project for deployment (including the runtime)
run Compiles and immediately executes a .NET project
repl Launch an interactive session (read, eval, print, loop)
pack Creates a NuGet package
C:\Users\Scott\Desktop\fabulous>dotnet new
Created new project in C:\Users\Scott\Desktop\fabulous.
C:\Users\Scott\Desktop\fabulous>dotnet restore
Microsoft .NET Development Utility CoreClr-x64-1.0.0-rc1-16231
CACHE https://www.myget.org/F/dotnet-core/api/v3/index.json
CACHE https://api.nuget.org/v3/index.json
Restoring packages for C:\Users\Scott\Desktop\fabulous\project.json
Writing lock file C:\Users\Scott\Desktop\fabulous\project.lock.json
Restore complete, 947ms elapsed
NuGet Config files used:
C:\Users\Scott\AppData\Roaming\NuGet\nuget.config
C:\Users\Scott\Desktop\nuget.config
C:\Users\Scott\Desktop\fabulous\nuget.config
Feeds used:
https://www.myget.org/F/dotnet-core/api/v3/flatcontainer/
https://api.nuget.org/v3-flatcontainer/
C:\Users\Scott\Desktop\fabulous>dotnet run
Hello World!
注意我这次在另一个工程之前运行dotnet,是为了不至于输出窗口看起来那么杂乱。
.NET应用程序的本地编译
这太棒了,但是当我们考虑本地是编译时,事情往往变得非常引人注目。字面上的意思就是我们的EXE编程了可以在本地平台执行的程序而不需要任何外部的组件。其实不是这样,.NET只是负责运行,并且运行很快。
那是早期的时候,那么现在仅仅是再现hello world和几个简单的样例,但本质上是当你在做“dotnet 编译”时,才能获得这些,是的,它需要.NET Core Runtime和所有支持的类库。JIT运行时就像你所了解和钟爱的.NET一样。
但是如过你做“dotnet 本地编译”,通过.NET Native chain运行,会产生大量的的EXE文件。但是这些EXE文件是独特的,本地的,并且只能运行。
再次说明,这是早期的情况,但是是非常令人激动的。在这浏览GitHub上的高层次工程计划。
相关项目
在GitHub上有许多相关的的项目。
· .NET首页回购 可以从微软和社区网站链接到数百个.NET项目
· .NET Core回购可以从微软网站链接到.NET Core的相关项目
· ASP.NET首页回购是最好的开始学习ASP.NET 5的地方
· https://dotnet.github.io是一个可以发现.NET功能的好地方。
Comments
- Anonymous
February 17, 2016
素晴らしい記事をお寄せいただきありがとうございます logsms.ir/.../121-%DA%86%D8%B1%D8%A7-%D8%A8%D8%A7%DB%8C%D8%AF-%D8%B3%DB%8C%D8%B3%D8%AA%D9%85-%D9%BE%D8%B4%D8%AA%DB%8C%D8%A8%D8%A7%D9%86%DB%8C-%D8%A2%D9%86%D9%84%D8%A7%DB%8C%D9%86-%D8%AF%D8%A7%D8%B4%D8%AA%D9%87-%D8%A8%D8%A7%D8%B4%D9%85-%D8%9F-%D9%85%D8%B9%D8%B1%D9%81%DB%8C-%D8%A8%D9%87%D8%AA%D8%B1%DB%8C%D9%86-%D8%B3%DB%8C%D8%B3%D8%AA%D9%85-%D9%87%D8%A7.html