Asp.net Core RC2 not detecting Reference to nuget package - asp.net-core

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.

Related

How can I add .NET framework 4.5.2 to 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

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"
}
}
...
}

.Net Core basic issue

I am new to this area. I already upgraded my VS2015 with update 3. So now I have: .Net Core 1.0.0 with preview tool 2 installed.
Then I use VS2015 to create a new .Net Source project (class library). I have copied some existing .net 4.6.1 code to the new place and compiled error as expected. Then I use "porting analyzer tool"(https://learn.microsoft.com/en-us/dotnet/articles/core/porting/index) to compare and it did give some suggestion how to use the new way in .Net Core.
But there are still few class missing and cannot compile, like 'TypeDescriptor' or 'NullableConverter' etc. Then I googled and someone from Github say they already added these feature but I still not sure why I still get compilation error.
I also noticed that my class libary project has a project.json file as:
"frameworks": {
"netstandard1.6": {
"imports": "dnxcore50"
}
}
I foundn if I remove the 'netstandard1.6' one but change to:
"frameworks": {
"net461": {}
}
All the compilation error gone, but I could guess it's NOT .Net core project anymore, and more likely as a standard .Net 4.6.1 project.
So basically I'd like to ask:
Why developer from Github saying that is fixed already but I still couldn't find/compile those classes in my project (e.g. TypeDescriptor : https://github.com/dotnet/corefx/issues/8262)?
Some sample also puts both 'net461' & 'netstard1.6' or 'netcoreapp1.0' under 'frameworks' in project.json file. What's the purpose for that?
If I just use 'net461' for the only framework, there seems no difference to traditional .Net Framework 4.6.1 project. Am I correct?
Thanks a lot!
Install package System.ComponentModel.TypeConverter and you are good to go with .NET Core project.
For building different output (binaries) each of which targeting different platform. net461 for applications which should run on (full) .NET Framework (under Windows or Mono). netcoreapp1.0 used for app which should be run under .NET Core. netstandard1.6 (avoid using netstandard1.5 and netstandard1.6 by the way - use previous versions) used for portable class libraries, which are supposed to run under different platforms: (full) .NET Framework, .NET Core, Xamarin, Universal Windows App, etc. You may read more about here and here.
Absolutely.

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.

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.