Search code examples
c#asp.net-corevisual-studio-2015console-applicationusing-directives

Why is Visual Studio not finding NuGet-packet types?


I am creating a .NET Core (version 1.0.0-rc1-update1) console application with VS 2015 community (latest version). Building and running the app went fine until I wanted to use any System.IO type (can not use System.Threading types either).

The name 'File' does not exist in the current context

I added the System.IO package with NPM and it added it to the dependency in the project.json. The project itself is running with dnx but Visual Studio can not build it.

project.json

{
    "version": "1.0.0-*",
    "description": "",
    "authors": [ "Widi" ],
    "tags": [ "" ],
    "projectUrl": "",
    "licenseUrl": "",

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

    "dependencies": {
        "OfcCore": "1.0.0-*",
        "System.IO": "4.0.11-beta-23516",
        "System.Text.RegularExpressions": "4.0.11-beta-23516"
    },

    "commands": {
        "Ofc": "Ofc"
    },

    "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"
            }
        }
    }
}

How do I get my project to also build and run in VS?

If I remove dnxcore50 VS builds like normal. It also seems like it can only not find the System.IO and System.Threading packages. System.Text.RegularExpressions works fine. Is there any special dependency I am missing?

Notes:

  • VS Community 14.0.24720.00 Update 1
  • ASP.NET and Web Tools 2015 (RC1 Update 1)

Solution

  • Whenever a class is missing, please use http://packagesearch.azurewebsites.net to locate the package you should add to project.json. Also you should only put NuGet dependencies under dnxcore50.