From d5a699eb7fc1243b41c278d73fa4c0b65c6d1417 Mon Sep 17 00:00:00 2001 From: Viktor Hofer Date: Mon, 10 Feb 2025 18:40:38 +0100 Subject: [PATCH 1/9] React to NuGet package pruning warnings Contributes to https://github.com/dotnet/sdk/pull/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. --- eng/packaging.targets | 618 +++++++++--------- ...Extensions.Diagnostics.Abstractions.csproj | 7 +- ...oft.Extensions.Logging.Abstractions.csproj | 5 + ...icrosoft.Extensions.Logging.Console.csproj | 5 +- .../ref/System.Formats.Nrbf.csproj | 4 +- .../ref/System.Memory.Data.csproj | 2 +- .../ref/System.Net.Http.Json.csproj | 8 +- 7 files changed, 332 insertions(+), 317 deletions(-) diff --git a/eng/packaging.targets b/eng/packaging.targets index c64ccfb2fcc393..74f9f805ca52f2 100644 --- a/eng/packaging.targets +++ b/eng/packaging.targets @@ -1,309 +1,309 @@ - - - - - true - - true - $(ApiCompatNetCoreAppBaselineVersion) - - $(BeforePack);IncludeAnalyzersInPackage;AddNETStandardCompatErrorFileForPackaging - $(TargetsForTfmSpecificContentInPackage);AddRuntimeSpecificFilesToPackage;IncludeProjectReferencesWithPackAttributeInPackage - - false - true - - true - $(MSBuildThisFileDirectory)useSharedDesignerContext.txt - - - true - PACKAGE.md - PACKAGE.md - $(BeforePack);ValidatePackageReadmeExists - - - true - true - - - false - - - - - true - - $(NoWarn);CP0003 - - - - - - - - - <_FrameworkAssemblyReferences Include="$(MSBuildProjectName)" - TargetFramework="$(NetFrameworkMinimum)" /> - - - - - - - - - - - - $(NoWarn);NU5128 - - - - - - - - - - - - - - - - - - $(TargetDir)$(TargetName).pdb - <_packageTargetRuntime>$(TargetPlatformIdentifier.ToLowerInvariant().Replace('windows', 'win')) - <_targetFrameworkWithoutSuffix>$(TargetFramework) - <_targetFrameworkWithoutSuffix Condition="$(TargetFramework.Contains('-'))">$(TargetFramework.SubString(0, $(TargetFramework.IndexOf('-')))) - - - - - - - <_RuntimeSymbolPath Include="@(TfmRuntimeSpecificPackageFile->'%(RootDir)%(Directory)%(FileName).pdb')" Condition="'%(TfmRuntimeSpecificPackageFile.Extension)' == '.dll'" KeepMetadata="None" /> - - - - - - - - - - - - - - <_TargetPathsToSymbols Include="@(_AnalyzerFile)" TargetPath="/%(_AnalyzerFile.PackagePath)" Condition="%(_AnalyzerFile.IsSymbol)" /> - - - - - <_MultiTargetRoslynComponentTargetsTemplate>$(MSBuildThisFileDirectory)MultiTargetRoslynComponent.targets.template - $(IntermediateOutputPath)MultiTargetRoslynComponent.targets - true - - - - - - - - - - - - - - - - - - <_MultiTargetRoslynComponentTargetPrefix>$(PackageId.Replace('.', '_')) - Disable$(PackageId.Replace('.', ''))SourceGenerator - - - - - - - - - <_NETStandardCompatErrorFilePath>$(BaseIntermediateOutputPath)netstandardcompaterror_%(NETStandardCompatError.Identity).targets - <_NETStandardCompatErrorFileTarget>NETStandardCompatError_$(PackageId.Replace('.', '_'))_$([System.String]::new('%(NETStandardCompatError.Supported)').Replace('.', '_')) - <_NETStandardCompatErrorFileContent> - - - - -]]> - - <_NETStandardCompatErrorPlaceholderFilePackagePath>buildTransitive$([System.IO.Path]::DirectorySeparatorChar)%(NETStandardCompatError.Supported) - - - - - - <_PackageBuildFile Include="@(None->Metadata('PackagePath')); - @(Content->Metadata('PackagePath'))" /> - <_PackageBuildFile PackagePathWithoutFilename="$([System.IO.Path]::GetDirectoryName('%(Identity)'))" /> - - - - - - - - - - <_referringTargetFramework>$(TargetFramework) - <_referringTargetFramework Condition="'$(PackageUsePlatformTargeting)' != 'true' and $(TargetFramework.Contains('-'))">$(TargetFramework.SubString(0, $(TargetFramework.IndexOf('-')))) - - - - - <_projectReferenceCopyLocalPaths Include="@(ReferenceCopyLocalPaths->WithMetadataValue('ReferenceSourceTarget', 'ProjectReference')->WithMetadataValue('Pack', 'true'))" /> - - - - - - - - - - - <_referenceAssemblyPaths Include="@(_projectReferenceCopyLocalPaths->WithMetadataValue('Extension', '.dll')->WithMetadataValue('IncludeReferenceAssemblyInPackage', 'true')->Metadata('ReferenceAssembly'))" /> - <_referenceAssemblyPaths Include="@(_projectReferenceCopyLocalPaths->WithMetadataValue('Extension', '.xml')->WithMetadataValue('IncludeReferenceAssemblyInPackage', 'true'))" /> - - - - - - - - net - netframework - - - - - - - <_BuildOutputPackageFile Include="$(OutputPath)**" - Exclude="$(OutputPath)publish\**; - $(OutputPath)" /> - - - - - - - - - - - - + + + + + true + + true + $(ApiCompatNetCoreAppBaselineVersion) + + $(BeforePack);IncludeAnalyzersInPackage;AddNETStandardCompatErrorFileForPackaging + $(TargetsForTfmSpecificContentInPackage);AddRuntimeSpecificFilesToPackage;IncludeProjectReferencesWithPackAttributeInPackage + + false + true + + true + $(MSBuildThisFileDirectory)useSharedDesignerContext.txt + + + true + PACKAGE.md + PACKAGE.md + $(BeforePack);ValidatePackageReadmeExists + + + true + true + + + false + + + + + true + + $(NoWarn);CP0003 + + + + + + + + + <_FrameworkAssemblyReferences Include="$(MSBuildProjectName)" + TargetFramework="$(NetFrameworkMinimum)" /> + + + + + + + + + + + + $(NoWarn);NU5128 + + + + + + + + + + + + + + + + + + $(TargetDir)$(TargetName).pdb + <_packageTargetRuntime>$(TargetPlatformIdentifier.ToLowerInvariant().Replace('windows', 'win')) + <_targetFrameworkWithoutSuffix>$(TargetFramework) + <_targetFrameworkWithoutSuffix Condition="$(TargetFramework.Contains('-'))">$(TargetFramework.SubString(0, $(TargetFramework.IndexOf('-')))) + + + + + + + <_RuntimeSymbolPath Include="@(TfmRuntimeSpecificPackageFile->'%(RootDir)%(Directory)%(FileName).pdb')" Condition="'%(TfmRuntimeSpecificPackageFile.Extension)' == '.dll'" KeepMetadata="None" /> + + + + + + + + + + + + + + <_TargetPathsToSymbols Include="@(_AnalyzerFile)" TargetPath="/%(_AnalyzerFile.PackagePath)" Condition="%(_AnalyzerFile.IsSymbol)" /> + + + + + <_MultiTargetRoslynComponentTargetsTemplate>$(MSBuildThisFileDirectory)MultiTargetRoslynComponent.targets.template + $(IntermediateOutputPath)MultiTargetRoslynComponent.targets + true + + + + + + + + + + + + + + + + + + <_MultiTargetRoslynComponentTargetPrefix>$(PackageId.Replace('.', '_')) + Disable$(PackageId.Replace('.', ''))SourceGenerator + + + + + + + + + <_NETStandardCompatErrorFilePath>$(BaseIntermediateOutputPath)netstandardcompaterror_%(NETStandardCompatError.Identity).targets + <_NETStandardCompatErrorFileTarget>NETStandardCompatError_$(PackageId.Replace('.', '_'))_$([System.String]::new('%(NETStandardCompatError.Supported)').Replace('.', '_')) + <_NETStandardCompatErrorFileContent> + + + + +]]> + + <_NETStandardCompatErrorPlaceholderFilePackagePath>buildTransitive$([System.IO.Path]::DirectorySeparatorChar)%(NETStandardCompatError.Supported) + + + + + + <_PackageBuildFile Include="@(None->Metadata('PackagePath')); + @(Content->Metadata('PackagePath'))" /> + <_PackageBuildFile PackagePathWithoutFilename="$([System.IO.Path]::GetDirectoryName('%(Identity)'))" /> + + + + + + + + + + <_referringTargetFramework>$(TargetFramework) + <_referringTargetFramework Condition="'$(PackageUsePlatformTargeting)' != 'true' and $(TargetFramework.Contains('-'))">$(TargetFramework.SubString(0, $(TargetFramework.IndexOf('-')))) + + + + + <_projectReferenceCopyLocalPaths Include="@(ReferenceCopyLocalPaths->WithMetadataValue('ReferenceSourceTarget', 'ProjectReference')->WithMetadataValue('Pack', 'true'))" /> + + + + + + + + + + + <_referenceAssemblyPaths Include="@(_projectReferenceCopyLocalPaths->WithMetadataValue('Extension', '.dll')->WithMetadataValue('IncludeReferenceAssemblyInPackage', 'true')->Metadata('ReferenceAssembly'))" /> + <_referenceAssemblyPaths Include="@(_projectReferenceCopyLocalPaths->WithMetadataValue('Extension', '.xml')->WithMetadataValue('IncludeReferenceAssemblyInPackage', 'true'))" /> + + + + + + + + net + netframework + + + + + + + <_BuildOutputPackageFile Include="$(OutputPath)**" + Exclude="$(OutputPath)publish\**; + $(OutputPath)" /> + + + + + + + + + + + + diff --git a/src/libraries/Microsoft.Extensions.Diagnostics.Abstractions/ref/Microsoft.Extensions.Diagnostics.Abstractions.csproj b/src/libraries/Microsoft.Extensions.Diagnostics.Abstractions/ref/Microsoft.Extensions.Diagnostics.Abstractions.csproj index f7b93cc292f7d7..63b868b9850364 100644 --- a/src/libraries/Microsoft.Extensions.Diagnostics.Abstractions/ref/Microsoft.Extensions.Diagnostics.Abstractions.csproj +++ b/src/libraries/Microsoft.Extensions.Diagnostics.Abstractions/ref/Microsoft.Extensions.Diagnostics.Abstractions.csproj @@ -1,4 +1,5 @@ + $(NetCoreAppCurrent);$(NetCoreAppPrevious);$(NetCoreAppMinimum);netstandard2.0;$(NetFrameworkMinimum) @@ -13,7 +14,11 @@ - + + + + + diff --git a/src/libraries/Microsoft.Extensions.Logging.Abstractions/ref/Microsoft.Extensions.Logging.Abstractions.csproj b/src/libraries/Microsoft.Extensions.Logging.Abstractions/ref/Microsoft.Extensions.Logging.Abstractions.csproj index ff6d90a86e99b2..9d4c9f5ccf4715 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Abstractions/ref/Microsoft.Extensions.Logging.Abstractions.csproj +++ b/src/libraries/Microsoft.Extensions.Logging.Abstractions/ref/Microsoft.Extensions.Logging.Abstractions.csproj @@ -1,4 +1,5 @@ + $(NetCoreAppCurrent);$(NetCoreAppPrevious);$(NetCoreAppMinimum);netstandard2.0;$(NetFrameworkMinimum) @@ -9,6 +10,10 @@ + + + + diff --git a/src/libraries/Microsoft.Extensions.Logging.Console/ref/Microsoft.Extensions.Logging.Console.csproj b/src/libraries/Microsoft.Extensions.Logging.Console/ref/Microsoft.Extensions.Logging.Console.csproj index 537f64f4fe43f5..92847d16a4f492 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Console/ref/Microsoft.Extensions.Logging.Console.csproj +++ b/src/libraries/Microsoft.Extensions.Logging.Console/ref/Microsoft.Extensions.Logging.Console.csproj @@ -18,11 +18,14 @@ - + + + + diff --git a/src/libraries/System.Formats.Nrbf/ref/System.Formats.Nrbf.csproj b/src/libraries/System.Formats.Nrbf/ref/System.Formats.Nrbf.csproj index 092064146e4fcf..1fcac9238bc8f7 100644 --- a/src/libraries/System.Formats.Nrbf/ref/System.Formats.Nrbf.csproj +++ b/src/libraries/System.Formats.Nrbf/ref/System.Formats.Nrbf.csproj @@ -1,4 +1,5 @@ + $(NetCoreAppCurrent);$(NetCoreAppPrevious);$(NetCoreAppMinimum);netstandard2.0;$(NetFrameworkMinimum) false @@ -8,7 +9,7 @@ - + @@ -21,4 +22,5 @@ + diff --git a/src/libraries/System.Memory.Data/ref/System.Memory.Data.csproj b/src/libraries/System.Memory.Data/ref/System.Memory.Data.csproj index 7d9b3481ecd82a..5f4d300cdabb9a 100644 --- a/src/libraries/System.Memory.Data/ref/System.Memory.Data.csproj +++ b/src/libraries/System.Memory.Data/ref/System.Memory.Data.csproj @@ -13,7 +13,7 @@ - + diff --git a/src/libraries/System.Net.Http.Json/ref/System.Net.Http.Json.csproj b/src/libraries/System.Net.Http.Json/ref/System.Net.Http.Json.csproj index 6b6cd6ec4cb172..f70e88607df434 100644 --- a/src/libraries/System.Net.Http.Json/ref/System.Net.Http.Json.csproj +++ b/src/libraries/System.Net.Http.Json/ref/System.Net.Http.Json.csproj @@ -17,16 +17,16 @@ - - - - + + + + From 505ebde977b2f47bebc85bebb0292c5041b42277 Mon Sep 17 00:00:00 2001 From: Viktor Hofer Date: Mon, 10 Feb 2025 19:33:03 +0100 Subject: [PATCH 2/9] Remove WarnOnProjectReferenceToFrameworkAssemblies target --- eng/packaging.targets | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/eng/packaging.targets b/eng/packaging.targets index 74f9f805ca52f2..e03c40614b42d7 100644 --- a/eng/packaging.targets +++ b/eng/packaging.targets @@ -170,21 +170,6 @@ - - - - - From dffea269afe9e40f1b6ea0b2d9a98b90f95483c6 Mon Sep 17 00:00:00 2001 From: Viktor Hofer Date: Mon, 10 Feb 2025 21:04:16 +0100 Subject: [PATCH 3/9] fix --- .../System.Net.Http.Json/ref/System.Net.Http.Json.csproj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libraries/System.Net.Http.Json/ref/System.Net.Http.Json.csproj b/src/libraries/System.Net.Http.Json/ref/System.Net.Http.Json.csproj index f70e88607df434..6b6cd6ec4cb172 100644 --- a/src/libraries/System.Net.Http.Json/ref/System.Net.Http.Json.csproj +++ b/src/libraries/System.Net.Http.Json/ref/System.Net.Http.Json.csproj @@ -17,16 +17,16 @@ + + + + - - - - From a45affd9a5490c10b53f72d1b8df3f4e20a04c63 Mon Sep 17 00:00:00 2001 From: Viktor Hofer Date: Mon, 10 Feb 2025 22:49:38 +0100 Subject: [PATCH 4/9] Aktualisieren von Microsoft.Extensions.Logging.Console.csproj --- .../ref/Microsoft.Extensions.Logging.Console.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/Microsoft.Extensions.Logging.Console/ref/Microsoft.Extensions.Logging.Console.csproj b/src/libraries/Microsoft.Extensions.Logging.Console/ref/Microsoft.Extensions.Logging.Console.csproj index 92847d16a4f492..f0353dbde2288e 100644 --- a/src/libraries/Microsoft.Extensions.Logging.Console/ref/Microsoft.Extensions.Logging.Console.csproj +++ b/src/libraries/Microsoft.Extensions.Logging.Console/ref/Microsoft.Extensions.Logging.Console.csproj @@ -24,7 +24,7 @@ - + From 2f3042ef5b9f9c4e5bb9d2aec37dbf6ec45e461f Mon Sep 17 00:00:00 2001 From: Viktor Hofer Date: Tue, 11 Feb 2025 09:10:37 +0100 Subject: [PATCH 5/9] Fix one more case --- .../src/System.Security.Cryptography.Pkcs.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Security.Cryptography.Pkcs/src/System.Security.Cryptography.Pkcs.csproj b/src/libraries/System.Security.Cryptography.Pkcs/src/System.Security.Cryptography.Pkcs.csproj index 168ec510fd0119..de6981cf994779 100644 --- a/src/libraries/System.Security.Cryptography.Pkcs/src/System.Security.Cryptography.Pkcs.csproj +++ b/src/libraries/System.Security.Cryptography.Pkcs/src/System.Security.Cryptography.Pkcs.csproj @@ -675,7 +675,7 @@ System.Security.Cryptography.Pkcs.EnvelopedCms - + From eea231041d4f9203a6d0e909533c1396978ca0a2 Mon Sep 17 00:00:00 2001 From: Viktor Hofer Date: Wed, 12 Feb 2025 10:43:52 +0100 Subject: [PATCH 6/9] Create PackageOverrides.txt in libs --- src/libraries/sfx-finish.proj | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/libraries/sfx-finish.proj b/src/libraries/sfx-finish.proj index ed1f35bd31d8b7..3db12b55c52298 100644 --- a/src/libraries/sfx-finish.proj +++ b/src/libraries/sfx-finish.proj @@ -7,11 +7,15 @@ $(MicrosoftNetCoreAppRefPackDataDir)FrameworkList.xml true - + $(InstallerProjectRoot)pkg\sfx\Microsoft.NETCore.App\PackageOverrides.txt + $(MicrosoftNetCoreAppRefPackDataDir)PackageOverrides.txt + + + @@ -51,6 +55,20 @@ RootAttributes="@(FrameworkListRootAttribute)" /> + + + + + + + + From 315be62917ed4b198444d58756dd17e26ad95bd3 Mon Sep 17 00:00:00 2001 From: Viktor Hofer Date: Wed, 12 Feb 2025 10:45:38 +0100 Subject: [PATCH 7/9] add empty line --- src/libraries/sfx-finish.proj | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libraries/sfx-finish.proj b/src/libraries/sfx-finish.proj index 3db12b55c52298..9f76ac74dcb651 100644 --- a/src/libraries/sfx-finish.proj +++ b/src/libraries/sfx-finish.proj @@ -11,6 +11,7 @@ $(InstallerProjectRoot)pkg\sfx\Microsoft.NETCore.App\PackageOverrides.txt $(MicrosoftNetCoreAppRefPackDataDir)PackageOverrides.txt + From d42919ba4cdb7a00342553c27998c744200728ed Mon Sep 17 00:00:00 2001 From: Viktor Hofer Date: Fri, 14 Feb 2025 12:28:09 +0100 Subject: [PATCH 8/9] Suppress NU1511 for false positives --- .../tests/AppHost.Bundle.Tests/AppHost.Bundle.Tests.csproj | 3 +++ .../Microsoft.DotNet.CoreSetup.Packaging.Tests.csproj | 6 +++--- .../Microsoft.NET.HostModel.Tests.csproj | 3 +++ src/installer/tests/TestUtils/TestUtils.csproj | 3 +++ 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/installer/tests/AppHost.Bundle.Tests/AppHost.Bundle.Tests.csproj b/src/installer/tests/AppHost.Bundle.Tests/AppHost.Bundle.Tests.csproj index c564835ae9e71e..13a9b59f64feb7 100644 --- a/src/installer/tests/AppHost.Bundle.Tests/AppHost.Bundle.Tests.csproj +++ b/src/installer/tests/AppHost.Bundle.Tests/AppHost.Bundle.Tests.csproj @@ -7,6 +7,9 @@ true ahb + + $(NoWarn);NU1511 diff --git a/src/installer/tests/Microsoft.DotNet.CoreSetup.Packaging.Tests/Microsoft.DotNet.CoreSetup.Packaging.Tests.csproj b/src/installer/tests/Microsoft.DotNet.CoreSetup.Packaging.Tests/Microsoft.DotNet.CoreSetup.Packaging.Tests.csproj index 4e01fdc25bd69d..49ccc41646dfc1 100644 --- a/src/installer/tests/Microsoft.DotNet.CoreSetup.Packaging.Tests/Microsoft.DotNet.CoreSetup.Packaging.Tests.csproj +++ b/src/installer/tests/Microsoft.DotNet.CoreSetup.Packaging.Tests/Microsoft.DotNet.CoreSetup.Packaging.Tests.csproj @@ -2,14 +2,14 @@ $(TestInfraTargetFramework) - false + + $(NoWarn);NU1511 - - diff --git a/src/installer/tests/Microsoft.NET.HostModel.Tests/Microsoft.NET.HostModel.Tests.csproj b/src/installer/tests/Microsoft.NET.HostModel.Tests/Microsoft.NET.HostModel.Tests.csproj index 053fe5b65fcfbb..a2782a71cbb943 100644 --- a/src/installer/tests/Microsoft.NET.HostModel.Tests/Microsoft.NET.HostModel.Tests.csproj +++ b/src/installer/tests/Microsoft.NET.HostModel.Tests/Microsoft.NET.HostModel.Tests.csproj @@ -6,6 +6,9 @@ true hm + + $(NoWarn);NU1511 diff --git a/src/installer/tests/TestUtils/TestUtils.csproj b/src/installer/tests/TestUtils/TestUtils.csproj index 268d4af5451fa3..2db347c9361631 100644 --- a/src/installer/tests/TestUtils/TestUtils.csproj +++ b/src/installer/tests/TestUtils/TestUtils.csproj @@ -5,6 +5,9 @@ true TestUtils TestUtils + + $(NoWarn);NU1511 From 29bba3c6fbe939b58fe32af408bdf4c87f548746 Mon Sep 17 00:00:00 2001 From: Viktor Hofer Date: Fri, 14 Feb 2025 14:47:02 +0100 Subject: [PATCH 9/9] One more hit --- .../tests/HostActivation.Tests/HostActivation.Tests.csproj | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/installer/tests/HostActivation.Tests/HostActivation.Tests.csproj b/src/installer/tests/HostActivation.Tests/HostActivation.Tests.csproj index 240237d85251f3..752922700de064 100644 --- a/src/installer/tests/HostActivation.Tests/HostActivation.Tests.csproj +++ b/src/installer/tests/HostActivation.Tests/HostActivation.Tests.csproj @@ -6,6 +6,9 @@ true ha + + $(NoWarn);NU1511