ASP.NET vNext Project Reference - asp.net-core

Does anybody know how to add project reference in ASP.NET vNext?
project.json
{
"dependencies": {
"myProject": ""
},
"configurations" : {
"net45" : { },
"k10" : { }
}
}
It doesn't work :(

I've found the solution.
You can use only ASP.NET vNext projects (I tried to use "Class library", but it works only with "ASP.NET vNext Classs Library"
You should use global.json to declare your folders.

when you save the project.json file,the References node in Solution Explorer shows the class library project and identifies it as a project in the properties window (other references such as Helios show up as NuGet package references).
if can not,you can try restart the vs

Related

ASP.Net 5 RC1 unresolved dependency: NU1001 The dependency ... >= 1.0.0-* could not be resolved

I hoping someone can help shed some light on how to get around this issue. I've noticed this issue while attempting to add a classic .csproj class library to a ASP.NET 5 RC1 xproj project and while attempting to add references to regualar .NET 4.5-4.6 assemblies to xproj based ASP.NET 5 RC1 projects. In this particular case I'm trying to add a reference to Microsoft.WindowsAzure.ServiceRuntime to an ASP.NET 5 WebApi project. I can see a wrap file get's generated that looks like this:
{
"version": "1.0.0-*",
"frameworks": {
"dnx46": {
"bin": {
"assembly": "../../lib/dnx46/Microsoft.WindowsAzure.ServiceRuntime.dll"
}
}
}
}
The reference in the project.json file looks like this:
"frameworks": {
"dnx46": {
"dependencies": {
"Microsoft.WindowsAzure.ServiceRuntime": "1.0.0-*"
}
}
},
When open up the project.lock.json file I see the following get added:
"DNX,Version=v4.6": [
"Microsoft.WindowsAzure.ServiceRuntime >= 1.0.0-*"
]
When I look at the references in visual studio I see the following:
What am I doing wrong? Is there any kind of workaround for this issue?

dnxcore50 framework support in ASP.Net 5 Class Library Package project?

I am trying to develop my first ASP.Net web application and in my solution I have two projects. A Web Application and Class Library (Package) and noticed that the Web App has this for it's framework inside the project.json
"frameworks": {
"dnxcore50": { }
}
My understanding is that code makes my Web App target Net 5.0 Core but if I look at the project.json for the Class Library I see this:
"frameworks": {
"net451": { },
"dotnet5.4": {
"dependencies": {
"Microsoft.CSharp": "4.0.1-beta-23516",
"System.Collections": "4.0.11-beta-23516",
"System.Linq": "4.0.1-beta-23516",
"System.Runtime": "4.0.21-beta-23516",
"System.Threading": "4.0.11-beta-23516"
}
}
}
I have never heard of dotnet5.4 and what I read from google just confuses me. I think the net451 is the equivalent to dnx451 but I am not 100% on that.
What do I need to change in my project.json to get it to target the new .Net 5.0 core?
This is the result of the upcoming .NET Standard Platform. You can see the changes regarding this specific to rc1 here, the main part being;
Only class libraries should change to target net4x and dotnet5.x. For
class libraries the recommended conversion steps are:
In project.json:
Change dnx4x to net4x (e.g. dnx451 to net451)
Change dnxcore50 to
dotnet5.4
And in your CS files:
Change #if DNX451 to #if NET451
Change #if DNXCORE50 to #if DOTNET5_4

System.InvalidOperationException : Migration failed

My solution have 3 projects :
Web (i added the connection string in the appsetting file)
Business (contains models class)
Infrastructure (contains DbContext)
I tried to make a migration :
dnx ef migration add firstMigration -s Web
I had this error :
System.InvalidOperationException: The current runtime target framework is not compatible with 'Infrastructure'.
Current runtime target framework: 'DNX,Version=v4.5.1 (dnx451)'
Version: 1.0.0-rc1-16202
Type: Clr
Architecture: x86
OS Name: Windows
OS Version: 10.0
Runtime Id: win10-x86
Please make sure the runtime matches a framework specified in project.json
When i put dnvm list, i have 1.0.0-rc1-final like a default runtime and i don't find 1.0.0*rc1-16202 in the list ?
The projet.json file of Infrastuture project is :
"frameworks": {
"dotnet5.4": {
},
"net451": {
"EntityFramework.Commands": "7.0.0-rc1-final",
"frameworkAssemblies": { "System.Runtime": "4.0.10.0" }
}
}
I had the same problem and I solved it by changing "net451" to "dnx451" in the project.json file under the "frameworks" object.
It's ok now, it was my mistake : i executed the command (dnx ef migrations add) in Infrasturtucre folder instead of web folder.

How do you make an ASP.Net 5 Application be able to consume class libraries?

Step 1: Open VS 2015 RC and create a new "ASP.Net Web Application"
Step 2: Right-click the solution, add a new windows "Class Library" (a normal one, not the "Class Library (Package)"
Step 3: Put a method in Class1.cs in the class library. Doesn't matter what.
Step 4: Right-click "References" in the Web Project and add a reference to your class library.
Step 5: From a code file in the web project, call the method you made in Class1.cs
So for me, Class1.cs looks like this:
public class Class1
{
public void X()
{
}
}
And I added code in the web application like this:
var x = new ClassLibrary1.Class1();
x.X();
Step 6: Try to compile, you will get this error:
Error CS0246 The type or namespace name 'ClassLibrary1' could not be found (are you missing a using directive or an assembly reference?)
What magic must be done to make normal class libraries (of which I have a lot) work with ASP.Net 5 apps?
When downloading your project and building, I got the following error in the output:
C:\REDACTED\AspNet5Test\src\AspNet5Test\Startup.cs(26,25,26,38): DNX Core 5.0 error CS0246: The type or namespace name 'ClassLibrary1' could not be found (are you missing a using directive or an assembly reference?)
Note, especially the DNX Core 5.0 portion - .Net 4.5 libraries (such as your ClassLibrary1) are not compatible with .Net Core.
The easiest solution is to remove the dependency on dnxcore50 from your project.json file.
Current:
"frameworks": {
"dnx451": {
"dependencies": {
"ClassLibrary1": "1.0.0-*"
}
},
"dnxcore50": { }
},
Change to:
"frameworks": {
"dnx451": {
"dependencies": {
"ClassLibrary1": "1.0.0-*"
}
}
},

How do I add a reference to a mono assembly in asp.net vNext

So I've installed Asp.net vNext onto my Linux box and have been playing around with it. I have everything set up and can build and run mvc applications. I'm building a console application and need to reference an assembly that doesn't exist in NuGet. I want to add a reference to Mono.Data.SqliteClient to my project.json. I know the path to the assembly /usr/local/lib/mono/4.5/Mono.Data.Sqlite.dll.
How do I add the reference to the dll? My project.json file currently looks like this:
{
"dependencies": {
"System.Console": "4.0.0.0",
"Dapper":"1.27",
"Mono.Data.Sqlite":""
},
"configurations": {
"net45": {},
"k10": {}
}
}
I found the answer on a forum...
In a nutshell, you can only reference your dlls if they are inside a nuget package... ( I hope this will be improved. It is a hassle IMO. )
The long story :
Ok, after a lot of fannying about, it seems that the way to do this is to create a nuget package using the DLL (i'll use Quartz version 2.2.4.400 as an example).
use http://docs.nuget.org/docs/creating-packages/using-a-gui-to-build-packages to build it. Drag and drop Quartz.dll into the right hand side (nb. it does need to be placed in the lib directory). File -> save as... save it in the following location:
projectRoot\packages\Quartz.2.2.4.400\Quartz.2.2.4.400.nupkg
With the dll in the following:
projectRoot\packages\Quartz.2.2.4.400\lib\Quartz.dll
nb. placing the DLL outside of the lib directory will compile alright, but won't work with intellisense. If you are compiling with a specific version, then i'd put it in a net45, net451 or k10 folder; as i'm not, I didn't bother. my project.json then looks like:
{
"dependencies": {
"Quartz" : "2.2.4.400"
},
"configurations" : {
"k10" : {
"dependencies": {
"System.Console": "4.0.0.0"
}
}
}
}