繁体   English   中英

无法在ASP.NET 5 dnx中构建控制台应用程序

[英]Unable to build a console application in ASP.NET 5 dnx

我无法使用Visual Studio Code在Debian上构建以下应用程序。 我错过了什么?

project.json

{
  "version": "1.0.0-*",
  "description": "ParseAB2Steps Console Application",
  "authors": [ "" ],
  "tags": [ "" ],
  "projectUrl": "",
  "licenseUrl": "",
  "tooling": {
    "defaultNamespace": "ParseAB2Steps"
  },

  "dependencies": {
  },

  "commands": {
    "ParseAB2Steps": "ParseAB2Steps"
  },

  "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",
        "System.IO": "4.0.11-beta-23516"
      }
    }
  }
}

Program.cs中

using System;
using System.IO;

namespace ParseAB2Steps
{
    public class Program
    {
        public static void Main(string[] args)
        {
            Console.WriteLine("Press enter to read ab2steps.md");
            Console.Read();

            string ab2steps = File.ReadAllText("/home/ab2/Dropbox/nodes/ab2/ab2-steps.md");
        }
    }
}

我在dnu builddnu build这个错误:

/home/ab2/projects/ParseAB2Steps/Program.cs(13,31):DNXCore,Version = v5.0错误CS0103:当前上下文中不存在名称“文件”

构建失败。

注意:我通过复制上一行中的版本手动将System.IO行放在project.json中,并且能够成功执行dnu restore

我也知道新的dotnet cli并且我没有升级到它,因为据我所知,Debian没有直接支持。 所以,我正在使用我目前拥有的dnx环境。

编辑2:

输出dnvm list

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

将依赖从System.IO更改为System.IO.FileSystem对我来说是个窍门。

您也可以将System.IO保留在文件中,但无论如何它都会被引入,因为它是少数其他程序集的依赖项,包括System.ConsoleSystem.IO.FileSystem

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM