'Trying to build from GitHub clone of 13.0.1 Newtonsoft.Json fails on net45 Dependencies - .NET Framework 4.5 Developer Pack is no longer available

We would like to use Newtonsoft.Json in a Class Library project that is targeting .NET Framework 4.7.2 with Visual Studio 2022.

The clone of the 13.0.1 solution from GitHub it fails to build.

First we get this error for Newtonsoft.Json:

Error   MSB3644 The reference assemblies for .NETFramework,Version=v4.5 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  Newtonsoft.Json C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets   1220    

And then many of these:

Error   NETSDK1141  Unable to resolve the .NET SDK version as specified in the global.json located at C:\Users\Kris\Source\Repos\Newtonsoft.Json\Src\global.json.   Newtonsoft.Json C:\Program Files\dotnet\sdk\6.0.202\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.DefaultItems.targets   127 

Indeed, the dependencies for net45 are missing. And they are no longer available for download: https://dotnet.microsoft.com/en-us/download/visual-studio-sdks?utm_source=getdotnetsdk&utm_medium=referral

The Newtonsoft.Json.Tests project had similar errors, but was complaining about net46. That developer pack is still available. We were able to install it, and it resolved the errors. But we can not do the same thing for net45.

For this application, we would prefer to have the Newtonsoft.Json source code in a local repo rather than using NuGet Package, if we can only get it to build without the deprecated developer pack.

I feel like there must be user error on our part, but the naïve attempts we've made to remove the net45 or substitute net472 in the "Target frameworks" semicolon-delimited list on the Application General properties page for the project have not had any positive benefit.

I suspect there must be a simple configuration change to the project/solution or a developer pack we can install that is available?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source