Development Environment:
Microsoft.NETCore.App 5.0.0-preview.5.20278.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
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 ?
NET 6 is not supported in VS2019.
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.
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). .
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With