After installing VS2022 , getting NU1201 error on .net framework 4.7.2

Shaul 1 Reputation point
2022-11-17T08:58:17.613+00:00

Hi,

I have developed on .net framework 4.7.2 and want to use .net6 on same machine , for that reason I have installed VS2022.
Everything were build perfectly on VS2019.
After installing VS2022 , getting NU1201 error on native projects of .NET framework 4.7.2 with VS2019:

When using NuGet.exe to restore Nugets for my projects:

set SolutionDir=%1
%SolutionDir%.nuget\NuGet.exe restore %SolutionDir%

Getting following errors on native projects running on VS2019 (Prior to VS2022 installation all passed successfully):

Errors in C:\GIT\XXX.vcxproj
NU1201: Project XXX is not compatible with native (native,Version=v0.0). Project XXX supports: net472 (.NETFramework,Version=v4.7.2)
NU1202: Package YYY 12.4.0 is not compatible with native (native,Version=v0.0). Package YYY 12.4.0 supports:
- net472 (.NETFramework,Version=v4.7.2)
- net50 (.NETFramework,Version=v5.0)
- netcoreapp3.1 (.NETCoreApp,Version=v3.1)
NU1202: Package Newtonsoft.Json 9.0.1 is not compatible with native (native,Version=v0.0). Package Newtonsoft.Json 9.0.1 supports:
- net20 (.NETFramework,Version=v2.0)
- net35 (.NETFramework,Version=v3.5)
- net40 (.NETFramework,Version=v4.0)
- net45 (.NETFramework,Version=v4.5)
- netstandard1.0 (.NETStandard,Version=v1.0)
- portable-net40+sl5+win8+wp8+wpa81 (.NETPortable,Version=v0.0,Profile=Profile328)
- portable-net45+win8+wp8+wpa81 (.NETPortable,Version=v0.0,Profile=Profile259)
NU1202: Package Microsoft.IdentityModel.Clients.ActiveDirectory 4.5.1 is not compatible with native (native,Version=v0.0). Package Microsoft.IdentityModel.Clients.ActiveDirectory 4.5.1 supports:
- monoandroid81 (MonoAndroid,Version=v8.1)
- net45 (.NETFramework,Version=v4.5)
- netstandard1.1 (.NETStandard,Version=v1.1)
- netstandard1.3 (.NETStandard,Version=v1.3)
- uap10.0 (UAP,Version=v10.0)
- xamarinios10 (Xamarin.iOS,Version=v1.0)

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,396 questions
Not Monitored
Not Monitored
Tag not monitored by Microsoft.
36,168 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Tianyu Sun-MSFT 27,356 Reputation points Microsoft Vendor
    2022-11-18T04:28:32.053+00:00

    Hi @Shaul ,

    Welcome to Microsoft Q&A forum.

    I suspect the NuGet cache causes this issue. I notice that you have uninstalled VS 2022, if you still consider using VS 2022, I suggest you reinstall VS 2022 and check if it works. If it still doesn’t work, please navigate to C:\Program Files\dotnet\sdk\NuGetFallbackFolder, backup this folder just in case, and remove the content, then try to restore NuGet packages for your projects again.

    Besides, here lists some other ways to clean NuGet cache, please also try them. If this issue persists, I recommend directly submitting a ticket on our Developer Community for further investigate.

    Feel free to contact us.

    Best Regards,
    Tianyu

    • If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
      Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
    0 comments No comments

  2. Ilya Nikulshin 0 Reputation points
    2023-03-30T10:08:16.3966667+00:00

    You must explicitly specify -MSBuildVersion option for NuGet.exe (https://learn.microsoft.com/en-us/nuget/reference/cli-reference/cli-ref-restore#options):

    By default the MSBuild in your path is picked, otherwise it defaults to the highest installed version of MSBuild.

    The best way I found to get a value for -MSBuildVersion option for VS2019 is:

    vswhere.exe -version "[16.0,17.0)" -latest -property installationVersion

    0 comments No comments