2016-05-31 65 views
3

我有四個庫項目都是針對netstandard1.5框架。其中一些取決於另一個,智能感知在這四個項目下運行良好。如何在Visual Studio 2015中修復引用netstandard1.5庫項目的智能感知?

我想在我的ASP.NET netcoreapp1.0項目中使用這些庫。但是當我瞄準netcoreapp1.0框架時,找不到類型(在visual studio中概述爲紅色)。項目編譯器成功編譯並運行。

只要我切換到我的web api中的netstandard1.5框架,庫的類型被識別,我得到intellisense。

任何想法如何解決這個問題或我做錯了什麼?

這裏是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" 
     ] 
    } 
    } 
} 
+0

在更改框架後是否還原了包? – svick

+0

我不知道多頻繁重複一次,但不要混用RC1和RC2軟件包! '「Microsoft.VisualStudio.Web.BrowserLink.Loader」:「14.0.0-rc1-final」' – Tseng

+0

我刪除了包但仍然得到相同的「錯誤」。之後也做了一次乾淨的重建。 也在解決方案根目錄和項目根目錄中執行了'dotnet restore'。 – Silthus

回答

4

ReSharper的是這裏的問題不視覺工作室。

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

ASP.NET核心1.0 RC2,包括在代碼完成,導航方面對標籤助手支持的初步支撐,搜索和重構。此時,如果ASP.NET Core Web應用程序以.NET Framework爲目標,但不支持,如果它們是以.NET Core爲目標的。我們希望在後續版本中提高這一點。

因此,如果您有一個庫定位.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" ] 
    } 
}, 
+0

奇怪的是,這也適用於VS 2017 Preview與netstandard2.0庫。在向netstandard2.0庫上的csproj添加第二個目標框架(coreapp)之後,Resharper正確顯示所有依賴關係/ intellisense ' netcoreapp2.0' ' netstandard2.0 Algirdas