I'm building an Asp.Net Core application. I recently installed .Net 6 Preview 7 on my machine.
Since the installation, I've been getting the following compiler errorS/warnings:
Error NU1100 Unable to resolve 'Microsoft.NETCore.App.Host.win-x64 (= 3.1.17)' for '.NETCoreApp,Version=v3.1'. SmartTracPoc.WebAPI C:\DevSandbox\LabelingSolutions\SmartTracPoc\SmartTracPoc.WebAPI\SmartTracPoc.WebAPI.csproj 1
Warning MSB3277 Found conflicts between different versions of "Microsoft.EntityFrameworkCore.Relational" that could not be resolved.
There was a conflict between "Microsoft.EntityFrameworkCore.Relational, Version=5.0.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60" and "Microsoft.EntityFrameworkCore.Relational, Version=5.0.4.0, Culture=neutral, PublicKeyToken=adb9793829ddae60".
"Microsoft.EntityFrameworkCore.Relational, Version=5.0.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60" was chosen because it was primary and "Microsoft.EntityFrameworkCore.Relational, Version=5.0.4.0, Culture=neutral, PublicKeyToken=adb9793829ddae60" was not.
References which depend on "Microsoft.EntityFrameworkCore.Relational, Version=5.0.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60" [C:\Users\jxbma.nuget\packages\microsoft.entityframeworkcore.relational\5.0.2\lib\netstandard2.1\Microsoft.EntityFrameworkCore.Relational.dll].
This is the TargetFramework from my project file:
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Configurations>Debug;Release;Debug-Local</Configurations>
</PropertyGroup>
How do I resolve this issue?
After installing, from a command prompt, you should be able to run “dotnet –info” and see something similar to the below :
But sometimes in Visual Studio, it ignores the preview version. At this time, you need to go to Tools -> Options, and then select the preview function according to the screenshot below. Make sure to check "Use Preview of .NET Core SDK". Without this, Visual Studio will use the latest version of the .NET SDK installed, which is not a preview version. Obviously, once .NET 6 is out of the preview version, you don’t need to do this, but if you try to use the latest and greatest version, you need to check this feature.
After setting, make sure to restart Visual Studio manually.
Then check the version:
<TargetFramework>net6.0</TargetFramework>