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.
Related
Trying to add the Nancy package to a new project. In project.json (dependencies segment) red squigly under "Nancy": "1.4.3". Mouseover displays an error relating to support for .NETCoreApp
The master branch of Nancy on github already runs on .net core.We are moving from Rake to Cake for the build script , hoping to wrap that up this week so .netcore support can be pushed to Nuget.So yes wait just a bit.
This example was original written on Stack Overflow Documentation:
Setup Nancyfx with Dotnet core v1.1, Kestrel, and Visual Studio Code on *nix systems
Prerequiste steps:
Get dotnet core for your platform:
Dotnet Core
Follow instructions and make sure dotnet core is working
Get Visual Studio Code for your platform:
VS Code
Launch Visual Studio Code (VS code) and install the C# extension then reload
Create self hosted NancyFx project:
Setup a project with a correct project directory structure.
Open Bash Terminal and type:
mkdir nancydotnetcore
cd nancydotnetcore
mkdir src
mkdir test
touch global.json
Open global.json and enter the following code:
{
"projects":["src", "test"]
}
In Bash terminal:
cd src
mkdir NancyProject1
dotnet new
Open folder NancyProject1 in VS code
You will get a warning: "Required assets to build and debug are missing from 'nancyproject1'."
Click "Yes"
Also you will see: There are unresolved dependencies from 'project.json'. Please execute the restore command to continue.
Click "Close" we will get to this soon.
Add the dependencies, open "project.json" and overwrite it with the following:
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true
},
"frameworks": {
"netcoreapp1.1": {
"dependencies": {
"Microsoft.AspNetCore.Hosting": "1.1.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.1.0",
"Microsoft.AspNetCore.Owin": "1.1.0",
"Nancy": "2.0.0-barneyrubble",
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.1.0"
}
}
}
}
}
VS code will ask to restore click "Restore"
Create folder "Modules" in VSCode project
In the Modules folder add a file named "IndexModule.cs" then copy and save the following:
namespace NancyProject1
{
using Nancy;
public class IndexModule : NancyModule
{
public IndexModule()
{
Get("/", _ => "Hello dotnet core world!");
}
}
}
In the root directory of the project create a file called "Startup.cs" and copy and paste the following:
namespace NancyProject1
{
using Microsoft.AspNetCore.Builder;
using Nancy.Owin;
public class Startup
{
public void Configure(IApplicationBuilder app)
{
app.UseOwin(x => x.UseNancy());
}
}
}
Open file "Program.cs" and overwrite the content with the following and save:
namespace NancyProject1
{
using System.IO;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
public class Program
{
public static void Main(string[] args)
{
var host = new WebHostBuilder()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseKestrel()
.UseStartup()
.Build();
host.Run();
}
}
}
Done! Now lets run this and see the output.
Click the debug symbol in VS Code, and Click the run button. It should compile and start the project.
Open the browser # http://localhost:5000
Pat yourself on the back and enjoy!
still pre release version but works with .net core as the time of this writing, view engines are very limited on core.
Install-Package Nancy -Version 2.0.0-barneyrubble -Pre
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
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-*"
}
}
},
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"
}
}
}
}
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