Enabling C# 6 in ASP.VNext projects in Visual Studio CTP2 - asp.net-core

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

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

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.

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.