Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual studio 2019 v16.6 can't build .net5 console application and raise errors: .NETFramework,Version=v5.0 were not found

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 ?

like image 883
M.Hassan Avatar asked Jun 22 '20 16:06

M.Hassan


People also ask

Does VS2019 support .NET 6?

NET 6 is not supported in VS2019.

Does VS2019 support .NET 5?

Starting with the June 2022 servicing update for Visual Studio 2019 16.11 and Visual Studio 2019 16.9, the . NET 5.0 component in Visual Studio will be changed to out of support and optional. This means that workloads in Visual Studio may be installed without installing . NET 5.0.

Does .NET 6 require Visual Studio 2022?

NET 6 is supported with Visual Studio 2022 and Visual Studio 2022 for Mac. It is not supported with Visual Studio 2019, Visual Studio for Mac 8, or MSBuild 16. If you want to use . NET 6, you will need to upgrade to Visual Studio 2022 (which is also now 64-bit). .


1 Answers

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.

like image 102
Fernando Margueirat Avatar answered Oct 19 '22 01:10

Fernando Margueirat