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

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

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

Microsoft.DotNet.Props not found

I'm installing .Net Core 1.0.1 and the lastest preview tooling for Visualt Studio 2015 Update 3.
I've created a project with .Net Core Web API. When I start the solution, it threw me an error box:
I created global.json for solution like this:
{
"projects": [ "Administration" ],
"sdk": {
"version": "1.0.1"
}
}
After that, I used command:
dotnet restore
I received one another error message:
The imported project "C:\Program Files\dotnet\sdk\1.0.1\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Props" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.
I got in the folder mentioned by the error message, but that path doesn't exist.
I wonder what is going on with my Visual Studio 2015 Community Update 3. Currently, I'm doing my company project, I cannot update my Visual Studio to 2017.
Can anyone help me please. I've spent my whole day searching for solutions but no luck.
Thank you,
The SDK versions and .Net Core versions are not the same. .net core SDK 1.0.1 is not .net core 1.0.1. The last SDK version that works with VS 2015 is Preview 2.
I resolved this error by uninstalling the SDK I had installed (in my case 1.0.4) and installing the latest SDK that works with VS 2015 which is 1.0.0-preview2-003131. You can find the Visual Studio 2015 tools on their downloads page.
A global.json that works for VS 2015 looks like this:
{
"projects": [],
"sdk": {
"version": "1.0.0-preview2-003131"
}
}

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.

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.

Enabling C# 6 in ASP.VNext projects in Visual Studio CTP2

I have installed Visual Studio CTP2 and created a new ASP.Net Vext project. When I tried using C# 6.0 features, it was not working. I even tried the stpes in the following link.
No C# 6.0 in Visual Studio 2015 CTP?
But even after this I was not able to use C# 6 in VNext projects. Please help.
Add this to your project.json:
"compilationOptions": {
"languageVersion": "experimental"
}
You should not add the net451 object. Use this inside the project.json file:
{
"compilationOptions": { "languageVersion": "experimental"},
"dependencies": {
},
"commands": {
}
}
I believe they also changed the default in the latest version of the engine. so the element is actually not needed anymore if you upgrade tje kvm to the lastest version.
see https://github.com/aspnet/KRuntime/pull/512
Upgrading can be done by running kvm upgrade at the command prompt.
see https://github.com/aspnet/Home/wiki/version-manager
HTH,
Bart