简体   繁体   English

ASP.NET vNext可以使用非vNext引用吗?

[英]Can ASP.NET vNext use non-vNext references?

So I have a ASP .NET vNext project in VS 14 CTP. 所以我在VS 14 CTP中有一个ASP .NET vNext项目。 I am targeting .NET Framework 4.5.1. 我的目标是.NET Framework 4.5.1。 I added a reference to a NuGet package, which does not have a build specific for vNext. 我添加了对NuGet包的引用,该包没有针对vNext的构建。

Visual Studio now shows usages of the package with no errors in the editor / Intellisense. Visual Studio现在显示编辑器/ Intellisense中没有错误的包的用法。 But when compiling, I get "The namespace 'MyPackage' not found" errors. 但是在编译时,我得到“未找到名称空间'MyPackage'”错误。

It was my understanding that I can add references to .NET Framework assemblies as long as I target the existing .NET Framework 4.5.1. 我的理解是,只要我定位现有的.NET Framework 4.5.1,我就可以添加对.NET Framework程序集的引用。 Is this not the case ? 这不是这种情况吗? Can I resolve this error ? 我可以解决此错误吗?

If you have both k10 and net451 frameworks listed in project.json, VS 14 by default builds project against both frameworks. 如果您在project.json中列出了k10和net451框架,则默认情况下,VS 14会针对这两个框架构建项目。 In such case if any of the assemblies are not built for k10 framework, build fails with package not found error. 在这种情况下,如果没有为k10框架构建任何程序集,则构建将失败并显示package not found错误。 So net 451 packages should specifically be added in net451 section of project.json. 因此,应特别在project.json的net451部分添加net 451软件包。 I am just pasting an example project.json where Microsoft.Bcl package is listed in net451 section 我只是粘贴一个示例project.json,其中Microsoft.Bcl包列在net451部分中

{
"dependencies": {
    "Microsoft.AspNet.Server.IIS": "1.0.0-*",
    "Microsoft.AspNet.Mvc": "6.0.0-*"
    <more packages>
},
"configurations": {
    "net451": {
        "dependencies": {
            "Microsoft.Bcl": "1.1.9"
            }        
  }
 }
}

According to ASP.NET improvements in Visual Studio 2015 CTP 5 , you will be able to reference standard projects from a vNext project. 根据Visual Studio 2015 CTP 5中的ASP.NET改进 ,您将能够从vNext项目中引用标准项目。 You can do this by simply using 'Add Reference' menu with right click, or manually adding it to the project.json under dependecies . 您可以通过右键单击“添加引用”菜单,或手动将其添加到dependecies下的project.json中来完成此操作。

Just avoid making cycling references (A references B and B references A) since that will cause Visual Studio to auto refresh the focus of your window on every 5 seconds. 只是避免制作循环引用(A引用B和B引用A),因为这将导致Visual Studio每5秒自动刷新窗口的焦点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM