.NET Core 1.0-最简单的Hello world控制台程序

使用任意的文本编辑软件,新建两个文件

1.Program.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace TestNuGetConsole
{
    public class Program
    {
        public static void Main(string[] args)
        {
            Console.WriteLine("Hello from DNX!");
        }
    }
}

2.project.json

{
  "version": "1.0.0-*",
  "description": "TestNuGetConsole Console Application",
  "authors": [ "eric" ],
  "tags": [ "" ],
  "projectUrl": "",
  "licenseUrl": "",

  "compilationOptions": {
    "emitEntryPoint": true
  },

  "dependencies": {
  },

  "commands": {
    "TestNuGetConsole": "TestNuGetConsole"
  },

  "frameworks": {
    "dnx451": { },
    "dnxcore50": {
      "dependencies": {
        "Microsoft.CSharp": "4.0.1-beta-23516",
        "System.Collections": "4.0.11-beta-23516",
        "System.Console": "4.0.0-beta-23516",
        "System.Linq": "4.0.1-beta-23516",
        "System.Threading": "4.0.11-beta-23516"
      }
    }
  }
}

Windows环境下

窗口+R,输入cmd,然后使用cd命令进入文件所在目录。

执行命令:dnu restore

image

等待下载包,执行成功的提示

image

执行命令:dnx run

image

成功完成!

CentOS环境下

基本与WIndows下一样

执行命令:dnu resotre

image

执行命令:dnx run

image

posted @ 2016-03-03 16:32  draweye  阅读(330)  评论(0编辑  收藏  举报