Skip to content

Add explicit Newtonsoft.Json reference to Rock.Blocks for VS 2026 builds - #10

Open
stphnlee wants to merge 1 commit into
hotfix-1.16.12from
sl-fix-rockblocks-newtonsoft-vs18
Open

stphnlee wants to merge 1 commit into
hotfix-1.16.12from
sl-fix-rockblocks-newtonsoft-vs18

Conversation

@stphnlee

Copy link
Copy Markdown

Problem

Building the Rock solution with VS 2026 (v18) fails Rock.Blocks with ~10x:

error CS0012: The type 'JObject' is defined in an assembly that is not referenced.
You must add a reference to assembly 'Newtonsoft.Json, Version=13.0.0.0, ...'

plus a cascading Could not get dependencies for project reference 'Rock.Blocks' from RockWeb. The identical tree builds clean under VS 2022.

Cause

Rock/Utility/ExtensionMethods/JsonExtensions.cs defines ToDictionary(this JObject) in namespace Rock, so every .ToDictionary()/LINQ binding in Rock.Blocks puts JObject in the overload-candidate set. Classic (non-SDK) csproj builds never pass transitive dependencies to csc, and Rock.Blocks has never referenced Newtonsoft.Json directly. VS 2026's Roslyn now requires the reference where VS 2022's did not.

Fix

Add the explicit Newtonsoft.Json 13.0.1 reference to Rock.Blocks.csproj + packages.config. The package is already in the solution packages folder and the DLL already ships in RockWeb\Bin, so there is no output change — this only lets the compile succeed.

Verified locally: VS 2026 MSBuild fails before / builds clean after; VS 2022 unaffected.

Forward-compat note

Upstream resolves this from v18.1 onward by converting Rock.Blocks to an SDK-style project (transitive refs flow to the compiler there). All 17.x hotfix branches still have the classic csproj without the reference, so this commit should be cherry-picked onto each future 1.16.x/17.x-based branch and dropped once we're on 18.1+.

🤖 Generated with Claude Code

VS 2026 (v18) MSBuild/Roslyn fails Rock.Blocks with CS0012 ('JObject is
defined in an assembly that is not referenced') at every call site that
binds .ToDictionary()/LINQ overloads, because Rock's
JsonExtensions.ToDictionary(this JObject) extension (namespace Rock) puts
JObject in the overload-candidate set and classic csproj builds never pass
transitive dependencies to the compiler. VS 2022 tolerated this; VS 2026
does not.

Add the reference explicitly (Newtonsoft.Json 13.0.1 is already in the
solution packages folder and ships in RockWeb\Bin, so no output change).
Upstream Rock resolves this from v18.1 onward by converting Rock.Blocks to
an SDK-style project; this commit is the stopgap for the 1.16.x/17.x lines
and should be cherry-picked onto future version branches until then.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings August 20, 2026 23:16

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses VS 2026 (v18) build failures by explicitly adding a Newtonsoft.Json reference to the classic (non-SDK) Rock.Blocks project so the compiler receives the required assembly reference.

Changes:

  • Added an explicit Newtonsoft.Json assembly reference to Rock.Blocks.csproj.
  • Added Newtonsoft.Json v13.0.1 to Rock.Blocks/packages.config so NuGet restore provides the referenced DLL.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
Rock.Blocks/Rock.Blocks.csproj Adds a direct Newtonsoft.Json reference (matching the same HintPath pattern used elsewhere in the solution) to satisfy VS 2026 compilation.
Rock.Blocks/packages.config Adds the NuGet package entry for Newtonsoft.Json 13.0.1 to support restore for the new reference.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants