如何使用 Visual Studio 2015 中引用的 netstandard1.5 库项目修复智能感知?

How to fix intellisense with referenced netstandard1.5 library projects in Visual Studio 2015?

我有四个库项目都以 netstandard1.5 框架为目标。其中一些依赖于另一个,智能感知在这四个项目下运行良好。

我正在尝试在我的 ASP.NET netcoreapp1.0 项目中使用这些库。但是当我以 netcoreapp1.0 框架为目标时,找不到类型(visual studio 中的红色轮廓)。工程hower编译运行成功

一旦我切换到我的网络 api 中的 netstandard1.5 框架,库的类型就会被识别,我会获得智能感知。

关于如何解决这个问题或我做错了什么有什么想法吗?

这是图书馆项目之一的 project.json(它们几乎相同):

{
  "version": "1.0.0-*",

  "frameworks": {
    "netstandard1.5": {
      "imports": [ "dnxcore50", "portable-net45+win8" ],
      "dependencies": {
        "NETStandard.Library": "1.5.0-rc2-24027",

        "System.Security.Principal": "4.0.1-rc2-24027"
      }
    }
  },
  "dependencies": {
    "Microsoft.AspNetCore.Identity": "1.0.0-rc2-final",
    "Microsoft.EntityFrameworkCore": "1.0.0-rc2-final",
    "HoehenSucht.Models": "1.0.0-*",
    "Microsoft.NETCore.Portable.Compatibility": "1.0.1-rc2-24027"
  }
}

这里是 api 的 project.json

{
  "version": "1.0.0-*",
  "buildOptions": {
    "emitEntryPoint": true
  },
  "dependencies": {
    "HoehenSucht.Framework": "1.0.0-*",
    "HoehenSucht.Models": "1.0.0-*",
    "HoehenSucht.Repositories": "1.0.0-*",
    "HoehenSucht.Services": "1.0.0-*",
    "HoehenSucht.Authentication": "1.0.0-*",
    "Microsoft.ApplicationInsights.AspNetCore": "1.0.0-rc2-final",
    "Microsoft.Extensions.Configuration": "1.0.0-rc2-final",
    "Microsoft.Extensions.Logging": "1.0.0-rc2-final",
    "Microsoft.Extensions.Logging.Console": "1.0.0-rc2-final",
    "Microsoft.Extensions.Logging.Debug": "1.0.0-rc2-final",
    "Autofac.Extensions.DependencyInjection": "4.0.0-rc2-240",
    "AutoMapper": "4.2.1",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-rc1-final",
    "System.Security.Principal": "4.0.1-rc2-24027",
    "System.Reflection": "4.1.0-rc2-24027",
    "IdentityServer4.AccessTokenValidation": "1.0.0-beta6",
    "Microsoft.AspNetCore.Authorization": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Diagnostics": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Mvc": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Hosting": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final",
    "Microsoft.EntityFrameworkCore": "1.0.0-rc2-final",
    "Microsoft.EntityFrameworkCore.SqlServer": "1.0.0-rc2-final",
    "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview1-final",
    "Autofac": "4.0.0-rc2-240",
    "Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.0.0-rc2-final",
    "HoehenSucht.API.Models": "1.0.0-*",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-rc2-final",
    "System.Linq": "4.1.0-rc2-24027",
    "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0-rc2-final",
    "Microsoft.Extensions.Configuration.Json": "1.0.0-rc2-final",
    "System.Linq.Parallel": "4.0.1-rc2-24027",
  },
  "frameworks": {
    "netcoreapp1.0": {
      "dependencies": {
        "Microsoft.NETCore.App": {
          "type": "platform",
          "version": "1.0.0-*"
        },
        "System.Collections": "4.0.11-rc2-24027",
      },
      "imports": [ "dnxcore50", "portable-net45+win8" ]
    }
  },
  "tools": {
    "Microsoft.EntityFrameworkCore.Tools": {
      "version": "1.0.0-preview1-final",
      "imports": [
        "portable-net45+win8+dnxcore50",
        "portable-net45+win8"
      ]
    }
  }
}

Resharper 不是这里的问题 Visual Studio。

http://blog.jetbrains.com/dotnet/2016/05/27/resharper-ultimate-2016-2-eap-kicks-off/

Initial support of ASP.NET Core 1.0 RC2, including support for tag helpers in terms of code completion, navigation, search and refactorings. At this point, ASP.NET Core web applications are supported if they’re targeting .NET Framework but are not supported if they’re targeting .NET Core. We’re looking to improve this in subsequent builds.

因此,如果您有针对 .netstandard1.5 的库,Resharper 将无法正确显示智能感知信息,但项目会编译。

但是,如果您将 .netcoreapp1.0 框架作为附加框架添加到 project.json 文件中,Resharper 将工作并且您将获得完整的智能感知支持。

 frameworks": {
    "netstandard1.5": {
      "imports": [ "dnxcore50", "portable-net45+win8" ],
      "dependencies": {
        "NETStandard.Library": "1.5.0-rc2-24027",

        "System.Security.Principal": "4.0.1-rc2-24027"
      }
    },
    ".netcoreapp1.0": {
      "imports": [ "dnxcore50", "portable-net45+win8" ]
    }
 },