Sunday, March 31, 2019

Getting .NET Core 3 Preview to Work in Visual Studio 2019

UPDATE UPDATE UPDATE
The steps listed below work for Visual Studio 2019 prior to 16.2.

In 16.2, the setting to "Use previews of the .NET Core SDK" has moved to the "Enviroment > Preview Features" section of the Options dialog:


UPDATE ENDS

ORIGINAL ARTICLE
Visual Studio 2019 just released (okay, it releases on Tuesday), and you're probably anxious to try out .NET Core 3.0 -- but that has *not* been released yet, and release date is TBD. But you can still download the .NET Core 3.0 Preview and use it in Visual Studio 2019.

But it is not available by default. Here's the short version: you have to enable it explicitly in Visual Studio.


From the "Tools" menu, select "Options", then navigate to "Projects and Solutions". Under there, you'll find a ".NET Core" node, and that has the setting we need.

Just check "Use previews of the .NET Core SDK", and you're good to go.

A big thanks to Brian Lagunas' video that showed me how to do this: [SOLVED] .NET Core 3 is not working with Visual Studio 2019.

Longer Version
So a couple weeks ago, I was excited to try out some .NET Core 3.0 (Preview) stuff to see how it works. Since we are really close to launch for Visual Studio 2019, I grabbed the latest version (which was the RC (release candidate)).

Visual Studio 2019 is available here: https://visualstudio.microsoft.com/downloads/

I also installed the latest preview of .NET Core 3.0 SDK. That is available here: https://dotnet.microsoft.com/download/dotnet-core/3.0

Then I created a new .NET Core console application. The new project dialog does not have a way to select the .NET Core version, so I figured that I would just go to the Project Options and change it myself.

I was a bit dismayed to see that .NET Core 3.0 was not available in my target framework dropdown:


A quick search led me to Brian Lagunas' video (mentioned above).

So then all I needed to do was go to Tools -> Options -> Projects and Solutions -> .NET Core.


Then I just checked the option for "Use previews of the .NET Core SDK".

When I restarted Visual Studio 2019, I saw the option pop up in the project options:


And then I was working with .NET Core 3.0 (Preview).

Initial Impressions
My initial impressions of .NET Core 3.0 are good. This is especially important when we look at what's happening with the .NET ecosystem (more on that in later articles).

I was most curious about the WPF support. I've converted most of my sample applications to use .NET Standard for the libraries, and .NET Core for the services. But I still have some WPF projects which are .NET Framework.

I was able to convert several of my WPF projects from .NET Framework to .NET Core 3.0 (Preview), and they ran just fine. (In some ways, they run better because it solves the NuGet issue that I brought up previously.)

So I've got some more exploration to do. There is also a bit of untangling because some features are cross platform, some are not. Also, since .NET Standard 2.1 does not support .NET Framework, there are some things that we need to be aware of -- particularly since there is one specific feature that is in .NET Standard 2.1 that I'd like to start using as quickly as possible.

Happy Coding!