Skip to content

Commit 31bd4d4

Browse files
authored
[release/5.0] Correct baseline checks (#25227)
- mostly duplicates #25217 - update `BaselineGenerator` to produce baselines useful in 6.0 (too) - update Baseline.Designer.props using new generator (matching 3.1.7 release) - always suppress references expressed only in `*.nuspec` files - needed even in servicing builds - restore warning and errors about removed references (new for 5.0) - adjust exclusions to handle `@(_ProjectReferenceByAssemblyName)` removal nit: do not generate empty `<ItemGroup />` elements * Correct `@(SuppressBaselineReference)` items - remove out-of-date `@(SuppressBaselineReference)` items - either 3.1.7 baselines we're using don't include reference or still using package - fix some comments and `Condition` attributes to make remainder easy to find - add missing `@(SuppressBaselineReference)` items
1 parent 7686c0b commit 31bd4d4

File tree

17 files changed

+139
-108
lines changed

17 files changed

+139
-108
lines changed

eng/Baseline.Designer.props

Lines changed: 42 additions & 58 deletions
Large diffs are not rendered by default.

eng/targets/ResolveReferences.targets

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,15 @@
175175

176176
<!-- Identify if any references were present in the last release of this package, but have been removed. -->
177177
<UnusedBaselinePackageReference Include="@(BaselinePackageReference)"
178-
Exclude="@(Reference);@(_ProjectReferenceByAssemblyName);@(PackageReference)" />
179-
<!-- Only allow suppressing baseline changes in non-servicing builds. -->
180-
<UnusedBaselinePackageReference Remove="@(SuppressBaselineReference)" Condition="'$(IsServicingBuild)' != 'true'"/>
178+
Exclude="@(Reference);@(PackageReference);@(ProjectReference->'%(Filename)')" />
179+
180+
<!-- Handle suppressions needed because above Exclude is not aware of references added in .nuspec files. -->
181+
<UnusedBaselinePackageReference Remove="@(SuppressBaselineReference->WithMetadataValue('InNuspecFile', 'true'))"
182+
Condition=" '$(IsServicingBuild)' == 'true' " />
183+
184+
<!-- Allow suppressions of any baseline changes in non-servicing builds. -->
185+
<UnusedBaselinePackageReference Remove="@(SuppressBaselineReference)"
186+
Condition=" '$(IsServicingBuild)' != 'true' " />
181187
</ItemGroup>
182188

183189
<JoinItems Left="@(Reference)" Right="@(LatestPackageReference)" LeftMetadata="*" RightMetadata="Version"
@@ -231,6 +237,16 @@
231237
<_ExplicitPackageReference Remove="@(_ExplicitPackageReference)" />
232238
</ItemGroup>
233239

240+
<Warning
241+
Condition=" '$(IsServicingBuild)' != 'true' AND '%(UnusedBaselinePackageReference.Identity)' != '' "
242+
Code="BUILD001"
243+
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." />
244+
245+
<Error
246+
Condition=" '$(IsServicingBuild)' == 'true' AND @(UnusedBaselinePackageReference->Count()) != 0 "
247+
Code="BUILD002"
248+
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 - ')" />
249+
234250
<Error
235251
Condition="'$(TargetFrameworkIdentifier)' != '.NETFramework' AND '%(Reference.Identity)' != '' AND ! Exists('%(Reference.Identity)') AND '$(DisablePackageReferenceRestrictions)' != 'true'"
236252
Code="MSB3245"

eng/tools/BaselineGenerator/Program.cs

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ static void Main(string[] args)
3636

3737
public Program()
3838
{
39-
_source = Option("-s|--package-source <SOURCE>", "The NuGet source of packages to fetch", CommandOptionType.SingleValue);
39+
_source = Option(
40+
"-s|--package-source <SOURCE>",
41+
"The NuGet source of packages to fetch",
42+
CommandOptionType.SingleValue);
4043
_output = Option("-o|--output <OUT>", "The generated file output path", CommandOptionType.SingleValue);
4144
_update = Option("-u|--update", "Regenerate the input (Baseline.xml) file.", CommandOptionType.NoValue);
4245

@@ -45,9 +48,6 @@ public Program()
4548

4649
private async Task<int> Run()
4750
{
48-
var source = _source.HasValue()
49-
? _source.Value().TrimEnd('/')
50-
: "https://api.nuget.org/v3/index.json";
5151
if (_output.HasValue() && _update.HasValue())
5252
{
5353
await Error.WriteLineAsync("'--output' and '--update' options must not be used together.");
@@ -56,6 +56,7 @@ private async Task<int> Run()
5656

5757
var inputPath = Path.Combine(Directory.GetCurrentDirectory(), "Baseline.xml");
5858
var input = XDocument.Load(inputPath);
59+
var source = _source.HasValue() ? _source.Value().TrimEnd('/') : "https://api.nuget.org/v3/index.json";
5960
var packageSource = new PackageSource(source);
6061
var providers = Repository.Provider.GetCoreV3(); // Get v2 and v3 API support
6162
var sourceRepository = new SourceRepository(packageSource, providers);
@@ -89,6 +90,11 @@ private async Task<int> Run()
8990

9091
var baselineVersion = input.Root.Attribute("Version").Value;
9192

93+
// Baseline and .NET Core versions always align in non-preview releases.
94+
var parsedVersion = Version.Parse(baselineVersion);
95+
var defaultTarget = ((parsedVersion.Major < 5) ? "netcoreapp" : "net") +
96+
$"{parsedVersion.Major}.{parsedVersion.Minor}";
97+
9298
var doc = new XDocument(
9399
new XComment(" Auto generated. Do not edit manually, use eng/tools/BaselineGenerator/ to recreate. "),
94100
new XElement("Project",
@@ -136,12 +142,34 @@ private async Task<int> Run()
136142

137143
foreach (var group in reader.NuspecReader.GetDependencyGroups())
138144
{
139-
var itemGroup = new XElement("ItemGroup", new XAttribute("Condition", $" '$(PackageId)' == '{id}' AND '$(TargetFramework)' == '{group.TargetFramework.GetShortFolderName()}' "));
145+
// Don't bother generating empty ItemGroup elements.
146+
if (group.Packages.Count() == 0)
147+
{
148+
continue;
149+
}
150+
151+
// Handle changes to $(DefaultNetCoreTargetFramework) even if some projects are held back.
152+
var targetCondition = $"'$(TargetFramework)' == '{group.TargetFramework.GetShortFolderName()}'";
153+
if (string.Equals(
154+
group.TargetFramework.GetShortFolderName(),
155+
defaultTarget,
156+
StringComparison.OrdinalIgnoreCase))
157+
{
158+
targetCondition =
159+
$"('$(TargetFramework)' == '$(DefaultNetCoreTargetFramework)' OR {targetCondition})";
160+
}
161+
162+
var itemGroup = new XElement(
163+
"ItemGroup",
164+
new XAttribute("Condition", $" '$(PackageId)' == '{id}' AND {targetCondition} "));
140165
doc.Root.Add(itemGroup);
141166

142167
foreach (var dependency in group.Packages)
143168
{
144-
itemGroup.Add(new XElement("BaselinePackageReference", new XAttribute("Include", dependency.Id), new XAttribute("Version", dependency.VersionRange.ToString())));
169+
itemGroup.Add(
170+
new XElement("BaselinePackageReference",
171+
new XAttribute("Include", dependency.Id),
172+
new XAttribute("Version", dependency.VersionRange.ToString())));
145173
}
146174
}
147175
}

src/Components/Components/src/Microsoft.AspNetCore.Components.csproj

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,17 @@
1717
<Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions" />
1818
</ItemGroup>
1919

20-
<!-- These references were removed in 3.0 -->
20+
<!--
21+
These references exist only in the .nuspec files and baseline checks are not aware of them. Keep suppressions
22+
in sync with the two .nuspec files:
23+
- Anytime a reference is added to this project file, remove its suppression.
24+
- Remove InNuspecFile attributes of references removed from the .nuspec files. Make suppression conditional on
25+
Major.Minor during previews. After RTM (and baseline updates), remove suppressions entirely.
26+
-->
2127
<ItemGroup>
22-
<SuppressBaselineReference Include="Microsoft.AspNetCore.Components.Analyzers" />
23-
<SuppressBaselineReference Include="Microsoft.AspNetCore.Authorization" />
24-
<SuppressBaselineReference Include="System.ComponentModel.Annotations" />
28+
<SuppressBaselineReference Include="Microsoft.AspNetCore.Components.Analyzers" InNuspecFile="true" />
29+
<SuppressBaselineReference Include="Microsoft.AspNetCore.Authorization" InNuspecFile="true" />
30+
<SuppressBaselineReference Include="Microsoft.JSInterop" Condition=" '$(AspNetCoreMajorMinorVersion)' == '5.0' " />
2531
</ItemGroup>
2632

2733
<Target Name="_GetNuspecDependencyPackageVersions">

src/Components/WebAssembly/WebAssembly/src/Microsoft.AspNetCore.Components.WebAssembly.csproj

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
@@ -15,9 +15,13 @@
1515
<Reference Include="Microsoft.Extensions.Logging" />
1616
<Reference Include="Microsoft.JSInterop.WebAssembly" />
1717

18-
<ProjectReference Include="..\..\..\Web.JS\Microsoft.AspNetCore.Components.Web.JS.npmproj" ReferenceOutputAssemblies="false" SkipGetTargetFrameworkProperties="true" UndefineProperties="TargetFramework" Private="false" Condition="'$(BuildNodeJS)' != 'false' and '$(BuildingInsideVisualStudio)' != 'true'" />
19-
20-
<SuppressBaselineReference Include="Microsoft.AspNetCore.Components.WebAssembly.HttpHandler" />
18+
<ProjectReference
19+
Include="..\..\..\Web.JS\Microsoft.AspNetCore.Components.Web.JS.npmproj"
20+
ReferenceOutputAssemblies="false"
21+
SkipGetTargetFrameworkProperties="true"
22+
UndefineProperties="TargetFramework"
23+
Private="false"
24+
Condition="'$(BuildNodeJS)' != 'false' and '$(BuildingInsideVisualStudio)' != 'true'" />
2125
</ItemGroup>
2226

2327
<ItemGroup>

src/DataProtection/DataProtection/src/Microsoft.AspNetCore.DataProtection.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929

3030
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
3131
<Reference Include="System.Security.Principal.Windows" />
32-
<SuppressBaselineReference Include="Microsoft.AspNetCore.Hosting.Abstractions" />
3332
</ItemGroup>
3433

3534
<ItemGroup Condition="'$(TargetFramework)' == '$(DefaultNetFxTargetFramework)'">

src/Hosting/TestHost/src/Microsoft.AspNetCore.TestHost.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,9 @@
1313
<Reference Include="Microsoft.Extensions.HostFactoryResolver.Sources" />
1414
</ItemGroup>
1515

16+
<ItemGroup Condition=" '$(AspNetCoreMajorMinorVersion)' == '5.0' ">
17+
<!-- Dependency (now in shared Fx) was removed in 5.0. Suppression can be removed after 5.0 RTM is released. -->
18+
<SuppressBaselineReference Include="System.IO.Pipelines" />
19+
</ItemGroup>
20+
1621
</Project>

src/Http/Http.Features/src/Microsoft.AspNetCore.Http.Features.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,9 @@
2020
<Reference Include="System.IO.Pipelines" />
2121
</ItemGroup>
2222

23+
<ItemGroup Condition=" '$(AspNetCoreMajorMinorVersion)' == '5.0' AND '$(TargetFramework)' == '$(DefaultNetCoreTargetFramework)' ">
24+
<!-- Dependency (now in shared Fx) was removed in 5.0. Suppression can be removed after 5.0 RTM is released. -->
25+
<SuppressBaselineReference Include="System.IO.Pipelines" />
26+
</ItemGroup>
27+
2328
</Project>

src/Identity/Extensions.Stores/src/Microsoft.Extensions.Identity.Stores.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
<Reference Include="Microsoft.Extensions.Caching.Abstractions" />
1414
<Reference Include="Microsoft.Extensions.Logging" />
1515
<Reference Include="Microsoft.Extensions.Identity.Core" />
16-
<SuppressBaselineReference Include="System.ComponentModel.Annotations" />
1716
</ItemGroup>
1817

1918
</Project>

src/Identity/Specification.Tests/src/Microsoft.AspNetCore.Identity.Specification.Tests.csproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,4 @@
2020
<Reference Include="xunit.analyzers" PrivateAssets="All" />
2121
</ItemGroup>
2222

23-
<ItemGroup>
24-
<!-- Removing nonexistent package -->
25-
<SuppressBaselineReference Include="Microsoft.AspNetCore.Testing" />
26-
</ItemGroup>
2723
</Project>

src/Identity/UI/src/Microsoft.AspNetCore.Identity.UI.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@
4242
<Reference Include="Microsoft.Extensions.Identity.Stores" />
4343
</ItemGroup>
4444

45+
<ItemGroup Condition=" '$(AspNetCoreMajorMinorVersion)' == '5.0' ">
46+
<!-- This dependency was removed in 5.0. The suppression can be removed after 5.0 RTM is released. -->
47+
<SuppressBaselineReference Include="Newtonsoft.Json" />
48+
</ItemGroup>
49+
4550
<ItemGroup>
4651
<UIFrameworkVersionMoniker Include="V4" />
4752
</ItemGroup>

src/Servers/Connections.Abstractions/src/Microsoft.AspNetCore.Connections.Abstractions.csproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,12 @@
2323
<Reference Include="Microsoft.Bcl.AsyncInterfaces" />
2424
</ItemGroup>
2525

26+
<ItemGroup Condition=" '$(AspNetCoreMajorMinorVersion)' == '5.0' ">
27+
<!--
28+
Dependency (now in shared Fx and a transitive ref for netstandard2.x) was removed in 5.0. Suppression can be
29+
removed after 5.0 RTM is released.
30+
-->
31+
<SuppressBaselineReference Include="System.IO.Pipelines" />
32+
</ItemGroup>
33+
2634
</Project>

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
<Reference Include="System.Threading.Channels" />
2828
</ItemGroup>
2929

30-
<ItemGroup Condition="'$(AspNetCoreMajorMinorVersion)' == '5.0'">
31-
<!-- This dependency was replaced by Protocols.NewtonsoftJson between 3.0 and 2.2. This suppression can be removed after 3.0 is complete. -->
32-
<SuppressBaselineReference Include="Microsoft.AspNetCore.SignalR.Protocols.Json" />
30+
<ItemGroup Condition=" '$(AspNetCoreMajorMinorVersion)' == '5.0' AND '$(TargetFramework)' == 'netstandard2.0' ">
31+
<!-- Dependency (a transitive ref) was removed in 5.0. Suppression can be removed after 5.0 RTM is released. -->
32+
<SuppressBaselineReference Include="Microsoft.Bcl.AsyncInterfaces" />
3333
</ItemGroup>
3434

3535
<ItemGroup>

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,4 @@
2323
<Reference Include="System.Text.Json" />
2424
</ItemGroup>
2525

26-
<ItemGroup Condition="'$(AspNetCoreMajorMinorVersion)' == '5.0'">
27-
<!-- This dependency was replaced by System.Text.Json between 3.0 and 2.2. This suppression can be removed after 3.0 is complete. -->
28-
<SuppressBaselineReference Include="Newtonsoft.Json" />
29-
30-
<!-- System.Text.Json (for .NET Standard 2.0) and ShardFx bring System.Buffers in (transitively). No need for both here. -->
31-
<SuppressBaselineReference Include="System.Buffers" />
32-
</ItemGroup>
33-
3426
</Project>

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,4 @@
2323
<Reference Include="Microsoft.AspNetCore.SignalR.Common" />
2424
</ItemGroup>
2525

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

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,6 @@
3333
<Reference Include="System.Net.Sockets" />
3434
</ItemGroup>
3535

36-
<ItemGroup Condition="'$(AspNetCoreMajorMinorVersion)' == '5.0'">
37-
<!-- This dependency was replaced by System.Text.Json between 3.0 and 2.2. This suppression can be removed after 3.0 is complete. -->
38-
<SuppressBaselineReference Include="Newtonsoft.Json" />
39-
40-
<!-- System.Text.Json (for .NET Standard 2.0) and ShardFx bring System.Buffers in (transitively). No need for both here. -->
41-
<SuppressBaselineReference Include="System.Buffers" />
42-
</ItemGroup>
43-
4436
<ItemGroup>
4537
<InternalsVisibleTo Include="Microsoft.AspNetCore.SignalR.Common.Tests" />
4638
<InternalsVisibleTo Include="Microsoft.AspNetCore.SignalR.Tests.Utils" />

src/Tools/dotnet-sql-cache/src/dotnet-sql-cache.csproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@
1515

1616
<ItemGroup>
1717
<Reference Include="Microsoft.Data.SqlClient" />
18-
19-
<!-- Intentional change to remove reference to System.Data.SqlClient. See https://github.com/dotnet/aspnetcore/issues/12445 -->
20-
<SuppressBaselineReference Include="System.Data.SqlClient" />
2118
</ItemGroup>
2219

2320
</Project>

0 commit comments

Comments
 (0)