Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can ASP.NET vNext use non-vNext references?

So I have a ASP .NET vNext project in VS 14 CTP. I am targeting .NET Framework 4.5.1. I added a reference to a NuGet package, which does not have a build specific for vNext.

Visual Studio now shows usages of the package with no errors in the editor / Intellisense. But when compiling, I get "The namespace 'MyPackage' not found" errors.

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. Is this not the case ? Can I resolve this error ?

like image 310
driis Avatar asked Aug 30 '14 17:08

driis


2 Answers

If you have both k10 and net451 frameworks listed in project.json, VS 14 by default builds project against both frameworks. In such case if any of the assemblies are not built for k10 framework, build fails with package not found error. So net 451 packages should specifically be added in net451 section of project.json. I am just pasting an example project.json where Microsoft.Bcl package is listed in net451 section

{ "dependencies": {     "Microsoft.AspNet.Server.IIS": "1.0.0-*",     "Microsoft.AspNet.Mvc": "6.0.0-*"     <more packages> }, "configurations": {     "net451": {         "dependencies": {             "Microsoft.Bcl": "1.1.9"             }           }  } } 
like image 180
Kirthi Krishnamraju Avatar answered Sep 27 '22 21:09

Kirthi Krishnamraju


According to ASP.NET improvements in Visual Studio 2015 CTP 5, you will be able to reference standard projects from a vNext project. You can do this by simply using 'Add Reference' menu with right click, or manually adding it to the project.json under dependecies.

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.

like image 29
Bogatinov Avatar answered Sep 27 '22 19:09

Bogatinov