Skip to content

Commit 607cbc3

Browse files
authored
Suppress warnings about breaking changes to Newtonsoft.Json dependency in SignalR (#9405)
1 parent 19e0030 commit 607cbc3

File tree

8 files changed

+61
-2
lines changed

8 files changed

+61
-2
lines changed

docs/BuildErrors.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Build Errors
2+
------------
3+
4+
This document is for common build errors and how to resolve them.
5+
6+
### Warning BUILD001
7+
8+
> warning BUILD001: Package references changed since the last release...
9+
10+
This warning indicates a breaking change might have been made to a package or assembly due to the removal of a reference which was used
11+
in a previous release of this assembly. See <./ReferenceResolution.md> for how to suppress.
12+
13+
### Error BUILD002
14+
15+
> error BUILD002: Package references changed since the last release...
16+
17+
Similar to BUILD001, but this error is not suppressable. This error only appears in servicing builds, which should not change references between assemblies or packages.

docs/ReferenceResolution.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ The requirements that led to this system are:
2525
* Name the .csproj file to match the assembly name.
2626
* Run `build.cmd /t:GenerateProjectList` when adding new projects
2727
* Use [eng/tools/BaseLineGenerator/](/eng/tools/BaselineGenerator/README.md) if you need to update baselines.
28+
* If you need to make a breaking change to dependencies, you may need to add `<SuppressBaselineReference>`.
2829

2930
## Important files
3031

@@ -67,3 +68,16 @@ Steps for adding a new package dependency to an existing project. Let's say I'm
6768

6869
If you don't know the commit hash of the source code used to produce "0.0.1-beta-1", you can use `000000` as a placeholder for `Sha`
6970
as its value is unimportant and will be updated the next time the bot runs.
71+
72+
## Example: make a breaking change to references
73+
74+
If Microsoft.AspNetCore.Banana in 2.1 had a reference to `Microsoft.AspNetCore.Orange`, but in 3.0 this reference is changing to `Microsoft.AspNetCore.BetterThanOrange`, you would need to make these changes to the .csproj file
75+
76+
```diff
77+
<!-- in Microsoft.AspNetCore.Banana.csproj -->
78+
<ItemGroup>
79+
- <Reference Include="Microsoft.AspNetCore.Orange" /> <!-- the old dependency -->
80+
+ <Reference Include="Microsoft.AspNetCore.BetterThanOrange" /> <!-- the new dependency -->
81+
+ <SuppressBaselineReference Include="Microsoft.AspNetCore.Orange" /> <!-- suppress as a known breaking change -->
82+
</ItemGroup>
83+
```

eng/targets/ResolveReferences.targets

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@
148148

149149
<!-- Identify if any references were present in the last release of this package, but have been removed. -->
150150
<UnusedBaselinePackageReference Include="@(BaselinePackageReference)" Exclude="@(Reference);@(_ProjectReferenceByAssemblyName);@(PackageReference)" />
151+
<!-- Only allow suppressing baseline changes in non-servicing builds. -->
152+
<UnusedBaselinePackageReference Remove="@(SuppressBaselineReference)" Condition="'$(IsServicingBuild)' != 'true'"/>
151153

152154
<!--
153155
MSBuild does not provide a way to join on matching identities in a Condition,
@@ -201,8 +203,13 @@
201203
<_ExplicitPackageReference Remove="@(_ExplicitPackageReference)" />
202204
</ItemGroup>
203205

204-
<Warning Condition="@(UnusedBaselinePackageReference->Count()) != 0"
205-
Text="Package references changed since the last release. This could be a breaking change. References removed:%0A - @(UnusedBaselinePackageReference, '%0A -')" />
206+
<Warning Condition="'$(IsReferenceAssemblyProject)' != 'true' AND '$(IsServicingBuild)' != 'true' AND '%(UnusedBaselinePackageReference.Identity)' != ''"
207+
Code="BUILD001"
208+
Text="Reference to '%(UnusedBaselinePackageReference.Identity)' was removed since the last stable release of this package. This could be a breaking change. See docs/ReferenceResolution.md for instructions on how to update changes to references or suppress this warning if the error was intentional." />
209+
210+
<Error Condition="'$(IsReferenceAssemblyProject)' != 'true' AND '$(IsServicingBuild)' == 'true' AND @(UnusedBaselinePackageReference->Count()) != 0"
211+
Code="BUILD002"
212+
Text="Package references changed since the last release. This could be a breaking change and is not allowed in a servicing update. References removed:%0A - @(UnusedBaselinePackageReference, '%0A -')" />
206213

207214
<Error Condition="'$(TargetFrameworkIdentifier)' != '.NETFramework' AND '%(Reference.Identity)' != '' AND ! Exists('%(Reference.Identity)') AND '$(DisablePackageReferenceRestrictions)' != 'true'"
208215
Code="MSB3245"

src/SignalR/clients/csharp/Client.Core/src/Microsoft.AspNetCore.SignalR.Client.Core.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,9 @@
2828
<Reference Include="System.Threading.Channels" />
2929
</ItemGroup>
3030

31+
<ItemGroup Condition="'$(AspNetCoreMajorMinorVersion)' == '3.0'">
32+
<!-- This dependency was replaced by Protocols.NewtonsoftJson between 3.0 and 2.2. This suppression can be removed after 3.0 is complete. -->
33+
<SuppressBaselineReference Include="Microsoft.AspNetCore.SignalR.Protocols.Json" />
34+
</ItemGroup>
35+
3136
</Project>

src/SignalR/common/Http.Connections.Common/src/Microsoft.AspNetCore.Http.Connections.Common.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,9 @@
2424
<Reference Include="System.Runtime.CompilerServices.Unsafe" />
2525
</ItemGroup>
2626

27+
<ItemGroup Condition="'$(AspNetCoreMajorMinorVersion)' == '3.0'">
28+
<!-- This dependency was replaced by System.Text.Json between 3.0 and 2.2. This suppression can be removed after 3.0 is complete. -->
29+
<SuppressBaselineReference Include="Newtonsoft.Json" />
30+
</ItemGroup>
31+
2732
</Project>

src/SignalR/common/Protocols.Json/src/Microsoft.AspNetCore.SignalR.Protocols.Json.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,9 @@
2727
<Reference Include="System.Runtime.CompilerServices.Unsafe" />
2828
</ItemGroup>
2929

30+
<ItemGroup Condition="'$(AspNetCoreMajorMinorVersion)' == '3.0'">
31+
<!-- This dependency was replaced by System.Text.Json between 3.0 and 2.2. This suppression can be removed after 3.0 is complete. -->
32+
<SuppressBaselineReference Include="Newtonsoft.Json" />
33+
</ItemGroup>
34+
3035
</Project>

src/SignalR/common/SignalR.Common/src/Microsoft.AspNetCore.SignalR.Common.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,9 @@
2929
<Reference Include="System.Runtime.CompilerServices.Unsafe" />
3030
</ItemGroup>
3131

32+
<ItemGroup Condition="'$(AspNetCoreMajorMinorVersion)' == '3.0'">
33+
<!-- This dependency was replaced by System.Text.Json between 3.0 and 2.2. This suppression can be removed after 3.0 is complete. -->
34+
<SuppressBaselineReference Include="Newtonsoft.Json" />
35+
</ItemGroup>
36+
3237
</Project>

version.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<PreReleaseBrandingLabel>Preview $(PreReleasePreviewNumber)</PreReleaseBrandingLabel>
99
<ExperimentalVersionPrefix>0.3.$(AspNetCorePatchVersion)</ExperimentalVersionPrefix>
1010
<BlazorComponentsVersionPrefix>0.9.$(AspNetCorePatchVersion)</BlazorComponentsVersionPrefix>
11+
<AspNetCoreMajorMinorVersion>$(AspNetCoreMajorVersion).$(AspNetCoreMinorVersion)</AspNetCoreMajorMinorVersion>
1112
<VersionPrefix>$(AspNetCoreMajorVersion).$(AspNetCoreMinorVersion).$(AspNetCorePatchVersion)</VersionPrefix>
1213

1314
<!-- ANCM versioning is intentionally 10 + AspNetCoreMajorVersion because earlier versions of ANCM shipped as 8.x. -->

0 commit comments

Comments
 (0)