简体   繁体   English

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

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

I am unable to build the following application on Debian with Visual Studio Code. 我无法使用Visual Studio Code在Debian上构建以下应用程序。 What am I missing? 我错过了什么?

project.json 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 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");
        }
    }
}

I get this error on dnu build : 我在dnu builddnu build这个错误:

/home/ab2/projects/ParseAB2Steps/Program.cs(13,31): DNXCore,Version=v5.0 error CS0103: The name 'File' does not exist in the current context /home/ab2/projects/ParseAB2Steps/Program.cs(13,31):DNXCore,Version = v5.0错误CS0103:当前上下文中不存在名称“文件”

Build failed. 构建失败。

Note: I put the System.IO line in the project.json manually by copying the version from the previous line and was able to do the dnu restore successfully. 注意:我通过复制上一行中的版本手动将System.IO行放在project.json中,并且能够成功执行dnu restore

I am also aware of the new dotnet cli and I did not upgrade to it as Debian is not directly supported as far as I know. 我也知道新的dotnet cli并且我没有升级到它,因为据我所知,Debian没有直接支持。 So, I am using the dnx environment which I currently have. 所以,我正在使用我目前拥有的dnx环境。

Edit 2: 编辑2:

Output of dnvm list 输出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       

Changing the dependency from System.IO to System.IO.FileSystem did the trick for me. 将依赖从System.IO更改为System.IO.FileSystem对我来说是个窍门。

You can leave System.IO in the file as well, but it's brought in anyway since it's a dependency of a few of the other assemblies, including System.Console and System.IO.FileSystem . 您也可以将System.IO保留在文件中,但无论如何它都会被引入,因为它是少数其他程序集的依赖项,包括System.ConsoleSystem.IO.FileSystem

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

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