.NET Core 2.0 Released!
Today’s header image was created by Alejandro Scaff at Unsplash
Ladies and Gentlemen, and friends beyond the binary,
to quote scooter
we interrupt your regularly scheduled series of posts to bring you this message:
The Week in .NET: .NET Core 2.0, Entity Framework Core 2.0, Visual Studio 2017 Update 3, and lots of links! https://t.co/qd1BcJhYth
— .NET Team (@dotnet) August 15, 2017
From that Tweet alone, we know that we have a lot of wonderful things to discuss. So let’s not waste any time, shall we?
.NET Standard 2.0
.NET Standard 2.0 is fully supported by .NET Core 2.0,
more on that in a moment
which is fantastic for everyone.
I’ve mentioned all of the wonderful things that where coming in .NET Standard 2.0 in my post on .NET Core 2.0 preview 1.
You can read what I had to say here
One of the biggest positives of .NET Standard 2.0’s release is that it brings the following platforms into line (API surface wise):
- .NET Framework 4.6.1
- .NET Core 2.0
- Mono 5.4
- Xamarin.iOS 10.14
- Xamarin.Mac 3.8
- Xamarin.Android 7.5
Meaning that the above platforms all have access to the same APIs when targeting .NET Standard 2.0.
which is pretty amazing, when you think about it. Big props to Immo and his team
Because .NET Standard 2.0 brings back a large chunk of the API surface, we’re now able to consume NuGet packages and DLLs which were originally built for .NET Framework in our .NET Core applications.
I wrote about how to do this before, back when the .NET Standard 2.0 preview was released (by using a .NET Framework NuGet package in a .NET Core 2.0 application).
Not much has changed, other than a new warning has been added into NuGet. Namely NuGet warning NU1071
wasn’t that the id for the Enterprise?
Here’s an example of NuGet warning NU1701:
Package ‘Microsoft.Composition 1.0.0’ was restored using ‘.NETFramework,Version=v4.6.1’ instead of the project target framework ‘.NETStandard,Version=v2.0’. This package may not be fully compatible with your project.
The above example warning will be displayed when adding a package built against .NET Framework, and whenever the project consuming that package is built. This is meant to force us (as the developers who are consuming the package) to do a sanity check on whether the package actually works with our code base.
This is due to the use of the .NET Framework compatibility mode:
The vast majority of NuGet packages are currently still targeting .NET Framework. Many projects are currently blocked from moving to .NET Standard because not all their dependencies are targeting .NET Standard yet.
at least it’s not as bad as the left-pad issue
This is all down to NuGet not being able to tell whether the package we’ve included will actually work with .NET Standard 2.0. It’s then down to us to ensure that the package works with our code, whilst we wait for the package maintainer to move it over to .NET Standard 2.0
if they move it over. There are a lot of very old packages on NuGet
For more on this warning, I’d recommend reading the Wiki entry for it over on the Github repo for NuGet at https://github.com/NuGet/Home/wiki/Improved-NuGet-warnings
it includes the steps you can take to force MSBuild to ignore the warning, but I wouldn’t recommend that. At least, for the time being
.NET Core 2.0
It really hasn’t been that long since preview 2 of .NET Core 2.0 was released.
in fact, the release notes for preview 2 where only created in June
which just shows Microsoft’s commitment to getting version 2.0 our of the door as soon as it was stable and ready for enterprise.
The official release date for .NET Core 2.0 was August 15th, 2017
meaning that it happened in the middle of my blog posting schedule 😛
The majority of the new stuff in .NET Core 2.0 was included in the two previews. I did a write up of the new content in preview one, back when it was the new hotness. Not much (functionality wise) has changed since then – there have been bug fixes and some performance improvements, but it’s mostly the same.
ASP.NET Core 2.0
Microsoft seem to be are hoping that Razor pages will be the killer feature for .NET Core 2.0
I’ve written about them already, too
I’m not sold on them as yet, but I can see how they could be useful as a training tool.
You could train someone to use Razor Pages before they go full MVC (creating separate Models, Views and Controllers directories and separating everything up that is – Razor Pages is part of MVC, you see), for instance. Also the source code for the ASP.NET Community Stand up website uses Razor Pages
the source for their site is available here
so it has it’s uses.
Personally (and this is just my opinion), it feels like it’s a step back towards webforms. Then again, React, Angular and similar JS UI frameworks have a mixture of code and markup in the same way. Maybe I just don’t like change as much as I used to.
There’s a whole new way to set up the webserver in ASP.NET Core 2.0.
again, I covered that in an earlier post when the first preview was released
Which OSs Are Supported?
Before we get onto the topic of installing and using .NET Core 2.0, it’ll be useful to know what we can run it on. The list of supported Operating Systems is impressive.
MacOS is the simplest, in that MacOS Sierra (version 10.12) and above is supported.
For Windows (desktop) it’s everything from Windows 7 SP1 onward. So Windows 8, 10 and Server 2008 (Revision 2, with Service Pack 1 at least) are supported.
Where things get simultaneously tricky, yet supremely impressive is with Linux distributions.
From here on out, the .NET Core team are targeting Linux rather than groups of distributions of Linux. The quickest and simplest way to explain this is to use the Linux support table that Microsoft have thrown together:
Theoretically, any Linux distribution which supports libc can run .NET Core 2.0. Add to that the fact that there’s now a proper ARM32 build of .NET Core 2.0 for Raspberry Pi, and you’ll see that we’re starting to converge on the promise that Java gave us (but never truly delivered on), back in the 1990s:
Write once, run anywhere
Which leads wonderfully to this beautiful image:
Installing .NET Core 2.0
Depending on the platform you’re on and whether you had the previews installed, you’ll need to take a slightly different path.
This is the easiest path by far.
which kind of betrays the fact that a lot of the .NET Core engineers are running MacOS
Simply install the latest version of the SDK – which you can find here: https://www.microsoft.com/net/core#macos
You’ll first need to update Visual Studio 2017 to version 15.3. This is done by opening the Programs & Features window, finding Visual Studio 2017 and clicking modify.
This will bring up the Visual Studio 2017 setup window, and might inform you that it need to be updated before you can update Visual Studio. Let that happen, then click the Update button.
you’ll need to close any instances of Visual Studio that you have open, first
As Immo himself points out
PSA: In order to use .NET Core 2.0/.NET Standard 2.0 in VS 15.3 you still need to install the .NET Core 2.0 SDK separately. https://t.co/u2brRiAZPm
— Immo Landwerth (@terrajobst) August 14, 2017
you’ll need to go install the latest version of the SDK – which you can find here: https://www.microsoft.com/net/core#windowscmd
Aside from Arch based Linux distributions, this is the hardest path (especially if you had one of the previews installed).
Arch used to require that you built from source
You’ll need to remove any of the preview builds that you previously had installed before you do anything.
The official instructions are pretty easy to follow
psst, they’re available here
but I had trouble with the following command:
|sudo apt remove dotnet-dev-2.0.0-preview2-006497|
I’d had both of the previews installed at one point, and it had left my system in a bit of a wobbly state. So I had to first run the following command to get a list of dotnet sdks installed:
|sudo apt list --installed | grep dotnet|
Then I had to run the following command to remove all SDK Version 2.0 previews:
|sudo apt remove dotnet-sdk-2*|
Only then I was able to run through the remainder of the set up process.
Confirming Installation of .NET Core 2.0
We’re going to use our old friend the terminal here
I’m a bit of a fan. I wonder whether you’ve noticed
Issuing the following command (one of our old friends):
If you get a different version, try searching in the directory you’re in for global.json files. When I first installed the .NET Core 2.0 release, I got the following back:
|> dotnet --version|
psst, lines prepended with ‘>’ are what I entered into the terminal
Which told me that there was a global.json somewhere. I did a search:
|> ls global.json|
|> cat global.json|
Then renamed it and checked the version number again:
|> mv global.json global.js|
|> dotnet --version|
I’ve already discussed updating Visual Studio 2017, but there are also updates for:
- Visual Studio for Mac
- Visual Studio Code
I had the preview installed, so already had all the features
Visual Studio for Mac should prompt you when you start it up. Let it download the updates and you’ll soon be ready to work with .NET Core 2.0. You’ll need to have installed the SDK separately, though.
as with Windows, it’s an opt-in process
You can download the latest version of Visual Studio Code from here: https://code.visualstudio.com/
Rider is an interesting one, because the first release was only a few weeks back
I’ve been using it since it was in early access, and now have the full version, so I’ll be putting my thoughts together soon.
Here’s a spoiler though: it’s great!
and that doesn’t support .NET Core 2.0’s features. Anyone with the 2.0 previews installed will have seen the familiar messages in the event log:
However, the official Rider twitter account had this to say on Wednesday (16th August, that is):
Rider 2017.2 EAP that supports .NET Core 2.0 will hopefully be available by the end of next week. https://t.co/Wv8Pw3yZWY
— JetBrains Rider (@JetBrainsRider) August 16, 2017
I Want More
Over the next few months, I’ll be putting out more .NET Core 2.0 specific posts
I need to get the OwaspHeaders middleware posts out of the way first
including a few where I’ll be taking some of the .NET Core 1.x projects and upgrading them to .NET Core 2.0 – which will be fun to write about, I’m sure 😛
Until then, I’d recommend that you take a look at this fantastic video with Scott Hunter and friends:
Scott goes through some of the newest features of .NET Core, ASP.NET Core, Visual Studio and Azure. It’s definitely worth watching, and it’s only 80 minutes long.
Have you started building applications or services with .NET Core 2.0? Had you built anything with the previews? What’s your favourite new feature?
How do you feel about .NET Standard 2.0 helping everything converge on the ‘any developer, any app, any platform’?
Let me know in the comments below, and let’s keep the conversation going