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

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

问题描述

我有四个库项目,它们都针对 netstandard1.5 框架。它们中的某些依赖于另一个,并且intellisense在这四个项目下都可以正常工作。

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内部的 netstandard1.5 框架, api识别了库的类型,我得到了智能感知。

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库项目修复intellisense?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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