昨天宣布 ASP.NET Core RC2,据说差不多稳定了,以后不会有大改了。
参考:https://blogs.msdn.microsoft.com/webdev/2016/05/16/announcing-asp-net-core-rc2/
一、环境装备
等待很久了,高兴之余昨晚安装一个CentOS系统,版本如下:
[[email protected] etc]# cat /etc/redhat-release CentOS Linux release 7.2.1511 (Core)
二、安装并执行hwapp
参考官网的Install for CentOS 7.1介绍,参考地址:https://www.microsoft.com/net/core#centos
安装官网的步骤一步一步的来~~下载可能很慢,直接从官网下载比较快~~
如果在执行 sudo ln -s ~/dotnet/dotnet /usr/local/bin 这个命令错误,错误如下:
[[email protected] 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中,所以需要手动添加。
解决方法,参考园有博客:http://www.cnblogs.com/evasnowind/archive/2011/02/04/1949113.html
安装完成之后,试一下:
[[email protected] ~]$ 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
[[email protected] ~]$ 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 [[email protected] ~]$
官网提供的HelloWorld实例,执行如下:
[[email protected] 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!
瞅瞅这个实例的目录结构:
[[email protected] dotnet]$ cd hwapp [[email protected] hwapp]$ ls bin obj Program.cs project.json project.lock.json [[email protected] hwapp]$ cd bin [[email protected] bin]$ ls Debug [[email protected] bin]$ cd Debug [[email protected] Debug]$ ls netcoreapp1.0 [[email protected] Debug]$ cd netcoreapp1.0/ [[email protected] netcoreapp1.0]$ ls hwapp.deps.json hwapp.pdb hwapp.runtimeconfig.json hwapp.dll hwapp.runtimeconfig.dev.json [[email protected] netcoreapp1.0]$
根目录跟平常开发没啥区别,多了 project.json project.lock.json 这两个文件。
三、project.json 与 project.lock.json
project.json很好理解,就是之前一堆配置的合并。
project.lock.json,参考:http://blog.falafel.com/what-is-project-lock-json/
时间: 2024-10-08 03:48:42