Skip to content

Commit ffece94

Browse files
authored
React to NuGet package pruning warnings (#112357)
* React to NuGet package pruning warnings Contributes to dotnet/sdk#46642 NuGet added a new feature that automatically prunes package and project references that are provided by the shared framework that is targeted. Resolve the few warnings that got emitted in ref projects when source-building the repository. * Remove WarnOnProjectReferenceToFrameworkAssemblies target * fix * Aktualisieren von Microsoft.Extensions.Logging.Console.csproj * Fix one more case * Create PackageOverrides.txt in libs * add empty line * Suppress NU1511 for false positives * One more hit
1 parent 42423ef commit ffece94

File tree

13 files changed

+348
-317
lines changed

13 files changed

+348
-317
lines changed

eng/packaging.targets

Lines changed: 294 additions & 309 deletions
Large diffs are not rendered by default.

src/installer/tests/AppHost.Bundle.Tests/AppHost.Bundle.Tests.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
88
<!-- Reduce the length of the test output dir to make it more reliable on Windows. -->
99
<TestsOutputName>ahb</TestsOutputName>
10+
<!-- NuGet warns about a transitive P2P to System.Text.Json that can't be pruned.
11+
This is a false positive: https://github.com/NuGet/Home/issues/14103 -->
12+
<NoWarn>$(NoWarn);NU1511</NoWarn>
1013
</PropertyGroup>
1114

1215
<ItemGroup>

src/installer/tests/HostActivation.Tests/HostActivation.Tests.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
77
<!-- Reduce the length of the test output dir to make it more reliable on Windows. -->
88
<TestsOutputName>ha</TestsOutputName>
9+
<!-- NuGet warns about a transitive P2P to System.Text.Json that can't be pruned.
10+
This is a false positive: https://github.com/NuGet/Home/issues/14103 -->
11+
<NoWarn>$(NoWarn);NU1511</NoWarn>
912
</PropertyGroup>
1013

1114
<ItemGroup>

src/installer/tests/Microsoft.DotNet.CoreSetup.Packaging.Tests/Microsoft.DotNet.CoreSetup.Packaging.Tests.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
<PropertyGroup>
44
<TargetFramework>$(TestInfraTargetFramework)</TargetFramework>
5-
65
<IsPackable>false</IsPackable>
6+
<!-- NuGet warns about a transitive P2P to System.Text.Json that can't be pruned.
7+
This is a false positive: https://github.com/NuGet/Home/issues/14103 -->
8+
<NoWarn>$(NoWarn);NU1511</NoWarn>
79
</PropertyGroup>
810

911
<ItemGroup>
1012
<PackageReference Include="NuGet.Packaging" Version="$(NugetPackagingVersion)" />
11-
<!-- Upgrade to a non-vulnerable version of Asn1 - which will be ignored in favor of the framework copy -->
12-
<PackageReference Include="System.Formats.Asn1" Version="$(SystemFormatsAsn1Version)" ExcludeAssets="All" />
1313
</ItemGroup>
1414

1515
<ItemGroup>

src/installer/tests/Microsoft.NET.HostModel.Tests/Microsoft.NET.HostModel.Tests.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
77
<!-- Reduce the length of the test output dir to make it more reliable on Windows. -->
88
<TestsOutputName>hm</TestsOutputName>
9+
<!-- NuGet warns about a transitive P2P to System.Text.Json that can't be pruned.
10+
This is a false positive: https://github.com/NuGet/Home/issues/14103 -->
11+
<NoWarn>$(NoWarn);NU1511</NoWarn>
912
</PropertyGroup>
1013

1114
<ItemGroup>

src/installer/tests/TestUtils/TestUtils.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
66
<AssemblyName>TestUtils</AssemblyName>
77
<PackageId>TestUtils</PackageId>
8+
<!-- NuGet warns about a transitive P2P to System.Text.Json that can't be pruned.
9+
This is a false positive: https://github.com/NuGet/Home/issues/14103 -->
10+
<NoWarn>$(NoWarn);NU1511</NoWarn>
811
</PropertyGroup>
912

1013
<ItemGroup>

src/libraries/Microsoft.Extensions.Diagnostics.Abstractions/ref/Microsoft.Extensions.Diagnostics.Abstractions.csproj

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2+
23
<PropertyGroup>
34
<TargetFrameworks>$(NetCoreAppCurrent);$(NetCoreAppPrevious);$(NetCoreAppMinimum);netstandard2.0;$(NetFrameworkMinimum)</TargetFrameworks>
45
</PropertyGroup>
@@ -13,7 +14,11 @@
1314
</ItemGroup>
1415

1516
<ItemGroup>
16-
<ProjectReference Include="$(LibrariesProjectRoot)System.Diagnostics.DiagnosticSource\ref\System.Diagnostics.DiagnosticSource.csproj" />
1717
<ProjectReference Include="$(LibrariesProjectRoot)Microsoft.Extensions.DependencyInjection.Abstractions\ref\Microsoft.Extensions.DependencyInjection.Abstractions.csproj" />
1818
</ItemGroup>
19+
20+
<ItemGroup Condition="'$(TargetFramework)' != '$(NetCoreAppCurrent)'">
21+
<ProjectReference Include="$(LibrariesProjectRoot)System.Diagnostics.DiagnosticSource\ref\System.Diagnostics.DiagnosticSource.csproj" />
22+
</ItemGroup>
23+
1924
</Project>

src/libraries/Microsoft.Extensions.Logging.Abstractions/ref/Microsoft.Extensions.Logging.Abstractions.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2+
23
<PropertyGroup>
34
<TargetFrameworks>$(NetCoreAppCurrent);$(NetCoreAppPrevious);$(NetCoreAppMinimum);netstandard2.0;$(NetFrameworkMinimum)</TargetFrameworks>
45
</PropertyGroup>
@@ -9,6 +10,10 @@
910

1011
<ItemGroup>
1112
<ProjectReference Include="$(LibrariesProjectRoot)Microsoft.Extensions.DependencyInjection.Abstractions\ref\Microsoft.Extensions.DependencyInjection.Abstractions.csproj" />
13+
</ItemGroup>
14+
15+
<ItemGroup Condition="'$(TargetFramework)' != '$(NetCoreAppCurrent)'">
1216
<ProjectReference Include="$(LibrariesProjectRoot)System.Diagnostics.DiagnosticSource\ref\System.Diagnostics.DiagnosticSource.csproj" />
1317
</ItemGroup>
18+
1419
</Project>

src/libraries/Microsoft.Extensions.Logging.Console/ref/Microsoft.Extensions.Logging.Console.csproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,14 @@
1818
</ItemGroup>
1919

2020
<ItemGroup>
21-
<ProjectReference Include="$(LibrariesProjectRoot)System.Text.Json\ref\System.Text.Json.csproj" />
2221
<ProjectReference Include="$(LibrariesProjectRoot)Microsoft.Extensions.Configuration.Abstractions\ref\Microsoft.Extensions.Configuration.Abstractions.csproj" />
2322
<ProjectReference Include="$(LibrariesProjectRoot)Microsoft.Extensions.Logging.Abstractions\ref\Microsoft.Extensions.Logging.Abstractions.csproj" />
2423
<ProjectReference Include="$(LibrariesProjectRoot)Microsoft.Extensions.Logging\ref\Microsoft.Extensions.Logging.csproj" />
2524
<ProjectReference Include="$(LibrariesProjectRoot)Microsoft.Extensions.Options\ref\Microsoft.Extensions.Options.csproj" />
2625
</ItemGroup>
2726

27+
<ItemGroup Condition="'$(TargetFramework)' != '$(NetCoreAppCurrent)'">
28+
<ProjectReference Include="$(LibrariesProjectRoot)System.Text.Json\ref\System.Text.Json.csproj" />
29+
</ItemGroup>
30+
2831
</Project>

src/libraries/System.Formats.Nrbf/ref/System.Formats.Nrbf.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2+
23
<PropertyGroup>
34
<TargetFrameworks>$(NetCoreAppCurrent);$(NetCoreAppPrevious);$(NetCoreAppMinimum);netstandard2.0;$(NetFrameworkMinimum)</TargetFrameworks>
45
<CLSCompliant>false</CLSCompliant>
@@ -8,7 +9,7 @@
89
<Compile Include="System.Formats.Nrbf.cs" />
910
</ItemGroup>
1011

11-
<ItemGroup>
12+
<ItemGroup Condition="'$(TargetFramework)' != '$(NetCoreAppCurrent)'">
1213
<ProjectReference Include="$(LibrariesProjectRoot)System.Reflection.Metadata\ref\System.Reflection.Metadata.csproj" />
1314
</ItemGroup>
1415

@@ -21,4 +22,5 @@
2122
<Compile Include="$(CoreLibSharedDir)System\Diagnostics\CodeAnalysis\RequiresDynamicCodeAttribute.cs" />
2223
<PackageReference Include="System.Memory" Version="$(SystemMemoryVersion)" />
2324
</ItemGroup>
25+
2426
</Project>

0 commit comments

Comments
 (0)