昨天宣佈 ASP.NET Core RC2,聽說差很少穩定了,之後不會有大改了。html
參考:https://blogs.msdn.microsoft.com/webdev/2016/05/16/announcing-asp-net-core-rc2/web
1、環境裝備json
等待好久了,高興之餘昨晚安裝一個CentOS系統,版本以下:centos
[root@bogon etc]# cat /etc/redhat-release CentOS Linux release 7.2.1511 (Core)
2、安裝並執行hwapp app
參考官網的Install for CentOS 7.1介紹,參考地址:https://www.microsoft.com/net/core#centoside
安裝官網的步驟一步一步的來~~下載可能很慢,直接從官網下載比較快~~ui
若是在執行 sudo ln -s ~/dotnet/dotnet /usr/local/bin 這個命令錯誤,錯誤以下:spa
[sonny@bogon dotnet]$ sudo ln -s ~/dotnet/dotnet /usr/local/bin We trust you have received the usual lecture from the local System Administrator. It usually boils down to these three things: #1) Respect the privacy of others. #2) Think before you type. #3) With great power comes great responsibility. [sudo] password for sonny: sonny is not in the sudoers file. This incident will be reported.
緣由:CentOS禁用的root用戶,而你新建的用戶並無添加到suduers中,因此須要手動添加。rest
解決方法,參考園有博客:http://www.cnblogs.com/evasnowind/archive/2011/02/04/1949113.htmlcode
安裝完成以後,試一下:
[sonny@bogon ~]$ dotnet --info .NET Command Line Tools (1.0.0-preview1-002702) Product Information: Version: 1.0.0-preview1-002702 Commit Sha: 6cde21225e Runtime Environment: OS Name: centos OS Version: 7 OS Platform: Linux RID: centos.7-x64
[sonny@bogon ~]$ dotnet --help .NET Command Line Tools (1.0.0-preview1-002702) 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 --version Display .NET CLI Version Number --info Display .NET CLI Info Common Commands: new Initialize a basic .NET project restore Restore dependencies specified in the .NET project build Builds a .NET project publish Publishes a .NET project for deployment (including the runtime) run Compiles and immediately executes a .NET project test Runs unit tests using the test runner specified in the project pack Creates a NuGet package [sonny@bogon ~]$
官網提供的HelloWorld實例,執行以下:
[sonny@bogon hwapp]$ dotnet run Project hwapp (.NETCoreApp,Version=v1.0) will be compiled because expected outputs are missing Compiling hwapp for .NETCoreApp,Version=v1.0 Compilation succeeded. 0 Warning(s) 0 Error(s) Time elapsed 00:00:05.8154656 Hello World!
瞅瞅這個實例的目錄結構:
[sonny@bogon dotnet]$ cd hwapp [sonny@bogon hwapp]$ ls bin obj Program.cs project.json project.lock.json [sonny@bogon hwapp]$ cd bin [sonny@bogon bin]$ ls Debug [sonny@bogon bin]$ cd Debug [sonny@bogon Debug]$ ls netcoreapp1.0 [sonny@bogon Debug]$ cd netcoreapp1.0/ [sonny@bogon netcoreapp1.0]$ ls hwapp.deps.json hwapp.pdb hwapp.runtimeconfig.json hwapp.dll hwapp.runtimeconfig.dev.json [sonny@bogon netcoreapp1.0]$
根目錄跟日常開發沒啥區別,多了 project.json project.lock.json 這兩個文件。
3、project.json 與 project.lock.json
project.json很好理解,就是以前一堆配置的合併。
project.lock.json,參考:http://blog.falafel.com/what-is-project-lock-json/