How can I add .NET framework 4.5.2 to Asp.Net Core - asp.net-core

If I click add reference I get
The following projects are not supported as references... AspNetCore version 1.0 and .NETFramework version 4.5.2
I follow this article but no success.
I changed the project.json with
"frameworks": {
"netcoreapp1.0": {
"imports": [
"dotnet5.6",
"portable-net45+win8"
]
},
"net452": {
"dependencies": {
"T4Generator": {
"target": "project"
}
}
}
},
And doesn't work, my .NET framework 4.5.2 is named T4Generator.
Is possible to add this project to Core?

There are two versions of .NET Core, .NET Standard version (Portable version, which you use in your project) and full .NET framework version.
If you choose portable version of .NET Core, then all the packages and libraries should be in .NET standard in order to use them. Unfortunately most of .NET framework packages are not ported to .NET standard yet.
Best way to solve your issue is converting your application to use full .NET Framework version of .NET Core. If not you can't use most of packages like T4Generator.
I would suggest you you to upgrade your project to use VS 2017 with csproj rather than project.json which is obsolete. Then convert.
Convert .Net Core to .Net Framework

Related

Updating a new asp.net core project to core 1.1 packages breaks the project

I just did a File new project in Visual Studio 2015 Community edition with update 3 and created a new Asp.NEt Core Mvc project.
I could build and start the project just fine.
Then I updated all nuget-packagges because many *.core.1.1 packages are available. After I did this, the project can no longer start when I do a simple f5. The browser opens and says the site cant be reached - probably because i fails to start. I tried setting a breakpoint in the main method in the Program.cs file, and that is not even hit. So it looks as if upgrading nuget packages breaks a standard ASP.Net Core project created from the official project template. The project is by deault set to use IIS Express.
Has anybody else experienced the same issue and found a solution ?
Did you follow the guide here: Announcing .NET Core 1.1?
Beside just updating your packages other changes are required, like update of frameworks section in project.json file:
{
...
"frameworks": {
"netcoreapp1.1": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.1.0"
}
},
"imports": "dnxcore50"
}
}
...
}

Asp.net Core RC2 not detecting Reference to nuget package

Im using Clean RC2 Template for web application.
after adding Reference to System.linq it gives me this :
Im using 461 as framework.
It's automatically restore back the package version to match the targeted framework version (net461).
So actually it's "detecting" nuget packages.
You trying to target 461 in the image, so the packages rolling back from .net core preview1 to .net framework 4.6.1 .
If you want target multiple framework (or as I see you want RC2 packages, meaning want .net core), your config.json file's frameworks section should look like this for example:
"frameworks": {
"net461": { // old .net framework
"dependencies":{
"System.LINQ": "4.0.0.0"
}
},
"netstandard1.5":{ // .net core
"dependencies":{
"System.LINQ": "4.1.0-RC2-*"
}
}
},
Here is a good info about targeting platforms
If you just want use .net core, remove the net461.
I see you want ASP.net core. Here is some cli ASP MVC samples.
Here is a really nice ASP.net core sample project (using latest .net core, you have to update to RTM/preview2)
You should already be able to use LINQ in your code (using System.Linq) without having to add a reference.
Since you are targeting .NET 461, you can add any additional GAC references in the frameworkAssemblies section in your project.json, e.g.
"frameworks": {
"net461": {
"frameworkAssemblies": {
"System.ServiceProcess": "4.0.0.0",
"System.Configuration": "4.0.0.0"
}
}
},
See this question for an explanation between dependencies and frameworkassemblies.

If ASP.NET 5 is being renamed ASP.NET Core 1.0, what is a new ASP.NET project targeting full .NET framework?

The offical docs say:
ASP.NET 5 is being renamed to ASP.NET Core 1.0
But what if I create a new ASP .NET 5 project in VS2015 today in the the project.json only target the dnx451:
"frameworks": {
"dnx451": { },
},
Surely this is not considered a "ASP .NET Core 1.0 project"! It is still possible to create ASP .NET 5 projects that do not use .NET Core and surely that won't be removed!?!?!
The project templates have been split into full .NET (using the net461 target framework) and .NET Core (using the netcoreapp1.0 target framework).
You can look at this question to see if both can be targeted at the same time.

Does dnx46 require at least .NET Framework 4.5.1?

In a new WebAPI project (trying ASP.NET Core 1.0) we have a requirement to query a legacy database "Pervasive SQL" using the ADO.NET Provider they provide. However they don't have a EF6 provider so we are stuck using EF5.
Skipping Entity Framework and using the ADO.NET PSqlConnection directly requires "System.Data 2.0.0.0". That makes me think the provider is compiled on .NET Framework 2.0 (or 3.5).
project.json
"frameworks": {
"net451": { },
"dnx46": {
"dependencies": {
"EntityFramework": "5.0.0",
"Pervasive.Data.SQLClient.Entity": "1.0.0-*",
"Pervasive.Data.SqlClient": "1.0.0-*",
"Pervasive.Data.Common": "1.0.0-*"
}
}
}
Running "dnu build" results into the following exception
xx\..\Controllers\ValuesController.cs(22,18): DNX,Version=v4.6 error CS0012: The type 'DbConnection' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
Build failed.
0 Warning(s)
2 Error(s)
The real question: Does dnx46 require at least .NET Framework 4.5.1 ?
Or is it somehow possible to referencing .NET Framework 3.5 (or 2.0) from ASP.NET Core 1.0?
The version of the moniker tells you already: It requires .NET Framework 4.6.
For 4.5.1 you need the dnx451 moniker.
But the essence is, 4.5 is minimum framework to use the new ASP.NET Core 1.0 (ASP.NET 5). You can see the matrix and how the moniker work on the ".Net Platform Standard" page on github.
Observations
If a library targets .NET Platform Standard version 1.3, it can only run on .NET Framework 4.6 or later, Universal Windows Platform 10 (UWP), DNX Core 5.0 and Mono/Xamarin platforms.
If a library targets .NET Platform Standard version 1.3, it can consume libraries from all previous .NET Platform Standard versions (1.2, 1.1, 1.0).
The earliest .NET Framework to support a .NET Platform Standard version is .NET Framework 4.5. This is because the new portable API surface area (aka System.Runtime based surface area) that is used as the foundation for the .NET Platform Standard only became available in that version of .NET Framework. Targeting .NET Framework <= 4.0 requires multi-targeting.
Each .NET Platform Standard version enables more API surface, which means it's available on fewer platforms. As the platforms update, their newer versions jump up into newer .NET Platform Standard versions.
Platforms which have stopped updating -- like Silverlight on Windows Phone -- will only ever be available in the earliest .NET Platform Standard versions.
Note
Please note that the moniker described there are for the current nightly builds. There are slight differences to the current RC1 release, i.e. it's dnx and dnxcore for dnx applications (ASP.NET, Console, unit-test projects) and net and dotnet for "Class Library (Package)". In RC2 current builds and RC it will be net and netstandard (also see this answer).

What does Asp.net 5 and Asp.net core 5 options under References in Visual studio 2015 mean?

When i tried to add reference in Visual studio 2015, i got confused seeing this 2 options under references "Asp.net5 and Asp.net core 5" .
Could any one please throw some light about that.
ASP.NET 5 is now a single framework that runs on top of either .NET Core 5 runtime (Core-CLR) or the .NET Framework runtime (CLR).
ASP.NET 5 is the first workload that has adopted .NET Core. ASP.NET 5 runs on both the .NET Framework and .NET Core. A key value of ASP.NET 5 is that it can run on multiple versions of .NET Core 5 on the same machine. Website A and website B can run on two different versions of .NET Core on the same machine, or they can use the same version.
It’s up to you. Due to its smaller footprint, there are also some performance benefits that are specific to .NET Core, however, most of the ASP.NET 5 performance benefits apply to both the .NET Framework and .NET Core.
When you add a nuget package to your project, it will be applicable to one or more frameworks. You add these packages in your project.json file in the 'dependencies' section.
"dependencies": {
"Microsoft.AspNet.Diagnostics.Entity": "7.0.0-*",
"Microsoft.AspNet.Identity": "3.0.0-*",
"Microsoft.AspNet.Mvc": "6.0.0-*",
"Microsoft.AspNet.Security.Cookies": "1.0.0-*",
"Microsoft.AspNet.Server.IIS": "1.0.0-*",
"Microsoft.AspNet.Server.WebListener": "1.0.0-*",
"Microsoft.AspNet.StaticFiles": "1.0.0-beta3",
"Microsoft.Framework.ConfigurationModel.Json": "1.0.0-*",
"Microsoft.Framework.CodeGenerators.Mvc": "1.0.0-*",
"Microsoft.Framework.Logging": "1.0.0-*",
"Microsoft.Framework.Logging.Console": "1.0.0-*",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-*"
}
The two main frameworks you will see are 'aspnet50' and 'aspcore50'. You will specify which framework(s) you would like to target in your project.json file.
"frameworks": {
"aspnet50": {
"frameworkAssemblies": {
},
"dependencies": {
}
},
"aspnetcore50": { }
}
In that section, you can also specify dependencies that you only want included for a specific framework. Inside your code, you will want to protect framework specific code.
#ifdef aspnet50
/* code targeting dependencies only available for aspnet50 */
#endif
The nodes you see under the 'References' node will visualize which packages are being included for which framework. The framework your application is running against will be configured in the application host.