Skip to content

Compiling version 12.0.3 from source? #3070

@donotsdubba

Description

@donotsdubba

Hello, thank you for not only an awesome, mega-popular library, but also for trying to target so many different platforms! My hats off to you for e.g. targeting .NET Framework 2.0 (Windows 98 compatible).

I wanted to compile Newtonsoft.Json myself using whatever is the latest version of it that still targeted PCLs (Portable Class Libraries), which turned out to be a somewhat recent version, 12.0.3, using either Visual Studio 2022 or 2019.

Thing is, even though I installed both versions of VS by checking the ".NET Portable Class Library Targeting Pack", and am able to compile any such projects when using the original, non-SDK-style project style, even "Profile1", I am unable to do so using an SDK-style C# project. This includes Newtonsoft.Json 12.0.3. My environment simply seems completely unable of handling/resolving the PCL-related TFMs, namely "portable-net45+win8+wpa81+wp8" and "portable-net40+win8+wpa81+wp8+sl5" in this case.

The exact error message I get is this, one error message per portable TFM:

Severity Code Description Project File Line Suppression State

Error NETSDK1005 Assets file 'C:\Users\%USERNAME%\Desktop\Newtonsoft.Json-12.0.3\Src\Newtonsoft.Json\obj\project.assets.json' doesn't have a target for '.NETPortable,Version=v0.0,Profile=Profile328'. Ensure that restore has run and that you have included 'portable-net40+sl5+win8+wp8+wpa81' in the TargetFrameworks for your project. Newtonsoft.Json C:\Program Files\dotnet\sdk\3.0.103\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets 234

Severity Code Description Project File Line Suppression State
Error NETSDK1005 Assets file 'C:\Users\%USERNAME%\Desktop\Newtonsoft.Json-12.0.3\Src\Newtonsoft.Json\obj\project.assets.json' doesn't have a target for '.NETPortable,Version=v0.0,Profile=Profile259'. Ensure that restore has run and that you have included 'portable-net45+win8+wp8+wpa81' in the TargetFrameworks for your project. Newtonsoft.Json C:\Program Files\dotnet\sdk\3.0.103\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets 234

I also have installed VS2008, VS2010, 2012, 2013 and 2017, full installs with their latest versions, so I should have all the required files for this targeting, I'd assume. I'm missing 2015, but I think that is not the problem. Or is it? EDIT: Turns out I also already had 2015 fully installed, too.

I also installed the latest Microsoft .NET Portable Library Reference Assemblies 4.6 , and followed the unzipping+copying instructions after installation as described in this StackOverflow thread (as per Cody's comment), but no dice.

So I'm clueless in figuring out how to compile this version of Newtonsoft.Json. Any help on how this was possible?

Many thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions