如何在 Visual Studio 2015 中使用引用的 netstandard1.5 库项目修复智能感知? [英] How to fix intellisense with referenced netstandard1.5 library projects in Visual Studio 2015?

查看:18
本文介绍了如何在 Visual Studio 2015 中使用引用的 netstandard1.5 库项目修复智能感知?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have four library projects that are all targeting the netstandard1.5 framework. Some of them depend on the other and the intellisense is working fine under those four projects.

我正在尝试在我的 ASP.NET netcoreapp1.0 项目中使用这些库.但是当我以 netcoreapp1.0 框架为目标时,找不到类型(在 Visual Studio 中用红色标出).项目如何编译运行成功.

I am trying to use these libraries inside my ASP.NET netcoreapp1.0 project. But when I target the netcoreapp1.0 framework the types are not found (outlined red in visual studio). The project hower compiles and runs successfully.

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

As soon as I switch to the netstandard1.5 framework inside my web api the types of the libraries are recognized and I get intellisense.

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

Any ideas on how to fix this or what I am doing wrong?

这是其中一个库项目的 project.json(它们几乎相同):

Here is the project.json for one of the library projects (they are almost identical):

{
  "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.

Resharper is the problem here not Visual Studio.

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

对 ASP.NET Core 1.0 RC2 的初步支持,包括在代码完成、导航、搜索和重构方面对标签助手的支持.此时,如果 ASP.NET Core Web 应用程序以 .NET Framework 为目标,则支持它们,但如果它们以 .NET Core 为目标,则不支持.我们希望在后续版本中改进这一点.

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 将无法正确显示智能感知信息,但项目将编译.

So if you have a library targeting .netstandard1.5 Resharper will not correctly display intellisense information but the project will compile.

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

However if you add the .netcoreapp1.0 framework as an additional framework to the project.json file Resharper will work and you get full intellisense support.

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

这篇关于如何在 Visual Studio 2015 中使用引用的 netstandard1.5 库项目修复智能感知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆