10

Development Environment:

  • Visual studio 2019 v16.6.2 is installed
  • .Net5 preview 5 is installed

Microsoft.NETCore.App 5.0.0-preview.5.20278.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

  • Enable the designer in Visual Studio
Tools > Options > Environment > Preview Features and select the Use the preview Windows Forms designer for .NET Core apps option. > re-start vs

I followed the instructions in this answer

I created a demo console project in .net5

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net5.0</TargetFramework>
  </PropertyGroup>  
</Project>

Then build and run using dotnet cli is ok

dotnet build  #ok
dotnet run # ok

Trying to build the project in visual studio fail with errors

Error MSB3644 The reference assemblies for .NETFramework,Version=v5.0 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks

Error NETSDK1005 Assets file 'F:\projects\Net5Demo\obj\project.assets.json' doesn't have a target for '.NETFramework,Version=v5.0'. Ensure that restore has run and that you have included 'net50' in the TargetFrameworks for your project.

What I missed to build and run the project using vs 2019 v16.6.2 ?

M.Hassan
  • 10,282
  • 5
  • 65
  • 84
  • The best way to guarantee that you have .NET 5.0 compatibility is to install the latest visual studio preview release: https://visualstudio.microsoft.com/vs/preview/ and the *latest* version of the .NET 5 Preview 8. (RC 1 just came out; so if you do that go to 16.8 preview 3) https://dotnet.microsoft.com/download/dotnet/5.0 – George Stocker Sep 15 '20 at 13:34

5 Answers5

5

As per https://dotnet.microsoft.com/download/dotnet/5.0 it looks like you also need VS 2019 16.8 preview 3 for it to recognize it.

Edit: I was having the same issue and after I installed VS 2019 16.8 preview 3 it started showing the option to use .NET 5.0.

1

Maybe you need to enable previews in Visual Studio:

Go to Tools > Options and enter Preview Features in the left panel.

Then in the right panel enable Use previews of the .NET Core SDK (requires restart)

enter image description here

Junior Mayhé
  • 16,144
  • 26
  • 115
  • 161
  • I enabled the preview option as I mentioned in my post based on this [answer](https://stackoverflow.com/questions/60843091/net-5-is-not-available-in-visual-studio-2019) – M.Hassan Jul 29 '20 at 12:40
  • some people indicate to install also Windows 10 SDK from Visual Studio installer. I have THIS SDK also installed. Not sure if it is needed. – Junior Mayhé Jul 30 '20 at 12:05
  • Windows 10 SDK is already installed. I think the root problem is that Vs 2019 16.6.x is not using MSbuild of Net5 SDK vs `VScode` or `dotnet build` who are using msbuild of sdk 5 and are working fine. – M.Hassan Jul 30 '20 at 14:25
  • 1
    I installed SDK 5.0.100-preview.7, latest Visual Studio 2019 version 16.6.5, Windows 10 SDK, on Visual Studio installer: Universal Windows Platform Development, NET desktop development, ASP.NET and Web Development, Azure development. The project in NET 5.0 builds fine. You could have a try and remove, remove and reinstall VS, but this time try the Visual Studio Preview version for testing https://visualstudio.microsoft.com/vs/preview/ – Junior Mayhé Aug 03 '20 at 18:27
  • Did you try to run c#9 in vs2019.6.5? – M.Hassan Aug 03 '20 at 20:24
  • Mayhe, vs 2019 v16.7 is released with Net 5 and c#9 support. – M.Hassan Aug 08 '20 at 09:58
1
  • Update Visual Studio to Visual Studio 2019 version 16.7 (released on Aug 5,2020 with support c# 9)
 help -> check for updates -> visual studio installer is displayed -> click update
  • Enable the designer in Visual Studio 2019 (as in OP).
  • Update to SDK 5.0.100-preview.7.

Just to check c# 9 availability, in the developer Command Prompt, type the command:

csc -langversion:?

You get:

Supported language versions:
default
1
2
3
4
5
6
7.0
7.1
7.2
7.3
8.0 (default)
9.0
latestmajor
preview
latest

The list above include 9.0 and you LangVersion can be defined as 9.0: The Console project with c# 9 support, can be:

<PropertyGroup>
  <OutputType>Exe</OutputType>
  <TargetFramework>net5.0</TargetFramework>
  <LangVersion>9.0</LangVersion> 
</PropertyGroup>

Now VS 2019 v16.7 can compile c# 9 in NET 5 successfully and IDE support C# 9.

Update: Sep15,2020

Vs 2019 16.7.3 is supporting only Preview7.

Full version
    5.0.100-preview.7.20366.6
Visual Studio support
    Visual Studio 2019 (v16.7, latest preview)
    Visual Studio 2019 for Mac (v8.7 preview)

In Download .Net 5 page, you can find the official VS2019 support. It seems that 16.7.3 is supporting only preview7.

M.Hassan
  • 10,282
  • 5
  • 65
  • 84
  • 1
    `dotnet -info` shows I have SDK `5.0.100-preview.8...`, My VS is `16.7.3`, and csc shows 9.0. My console app PropertyGroup looks the same as yours. I still get this error. I believe the root cause is that I do not have a v5.0 folder in `C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETCore` – Suamere Sep 12 '20 at 15:27
  • 1
    In [Download .Net 5 page](https://dotnet.microsoft.com/download/dotnet/5.0), you can find the official VS2019 support. It seems that 16.7.x is supporting only preview7. – M.Hassan Sep 15 '20 at 13:13
0

Have you downloaded the x64 or the x86 version of the SDK?

You may try to download the preview 6.

ycrumeyrolle
  • 495
  • 4
  • 15
0

My VS is 16.7.3 (the latest). But, when I install, SDK 5.0.100-preview.8, I don't see .Net 5.0 on my Target framework. But, after uninstalling it and reinstalling SDK 5.0.100-preview.7, I could see it.

  • In [Download .Net 5 page](https://dotnet.microsoft.com/download/dotnet/5.0), you can find the official VS2019 support. It seems that 16.7.x is supporting only preview7. – M.Hassan Sep 15 '20 at 13:14