在Linux上运行.NET Core - 什么都不写

时间:2015-12-01 07:49:09

标签: c# .net linux mono coreclr

我在Visual Studio中创建了项目vNext控制台应用程序。我将这些文件复制到linux机器上。并尝试运行它们

ubuntu@ubuntu-Virtual-Machine:~/ConsoleApp2/src/ConsoleApp2$ dnvm list

Active Version              Runtime Architecture OperatingSystem Alias
------ -------              ------- ------------ --------------- -----
  *    1.0.0-rc1-final      coreclr x64          linux           
       1.0.0-rc1-final      mono                 linux/osx       default

ubuntu@ubuntu-Virtual-Machine:~/ConsoleApp2/src/ConsoleApp2$ dnu restore
ubuntu@ubuntu-Virtual-Machine:~/ConsoleApp2/src/ConsoleApp2$ dnx run
ubuntu@ubuntu-Virtual-Machine:~/ConsoleApp2/src/ConsoleApp2$

我的应用程序未运行。但是,如果我将dnvm切换为单声道,它可以正常工作。 我的文件内容是

Program.cs的

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

namespace ConsoleApp2
{
    public class Program
    {
        public void Main(string[] args)
        {
            Console.WriteLine("Hello world!!!!");
            Console.Read();
        }
    }
}

project.json

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

  "dependencies": {

  },

  "frameworks": {
    "dnx451": {},
    "dnxcore50": {
      "dependencies": {

        "System.Console": "4.0.0-beta-23019",
        "System.Linq": "4.0.0-beta-23019",
        "System.Threading": "4.0.10-beta-23019",
        "Microsoft.CSharp": "4.0.0-beta-23019"
      }
    }
  }
}

为什么dnx命令在切换到coreclr时什么都不写?

1 个答案:

答案 0 :(得分:0)

大多数情况下,您确定缺少其中一项先决条件。它们列在here

sudo apt-get install libunwind8 gettext libssl-dev libcurl4-openssl-dev zlib1g libicu-dev uuid-dev