Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React to NuGet package pruning warnings #112357

Merged
merged 9 commits into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
603 changes: 294 additions & 309 deletions eng/packaging.targets
ViktorHofer marked this conversation as resolved.
Show resolved Hide resolved

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<!-- Reduce the length of the test output dir to make it more reliable on Windows. -->
<TestsOutputName>ahb</TestsOutputName>
<!-- NuGet warns about a transitive P2P to System.Text.Json that can't be pruned.
This is a false positive: https://github.com/NuGet/Home/issues/14103 -->
<NoWarn>$(NoWarn);NU1511</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<!-- Reduce the length of the test output dir to make it more reliable on Windows. -->
<TestsOutputName>ha</TestsOutputName>
<!-- NuGet warns about a transitive P2P to System.Text.Json that can't be pruned.
This is a false positive: https://github.com/NuGet/Home/issues/14103 -->
<NoWarn>$(NoWarn);NU1511</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

<PropertyGroup>
<TargetFramework>$(TestInfraTargetFramework)</TargetFramework>

<IsPackable>false</IsPackable>
<!-- NuGet warns about a transitive P2P to System.Text.Json that can't be pruned.
This is a false positive: https://github.com/NuGet/Home/issues/14103 -->
<NoWarn>$(NoWarn);NU1511</NoWarn>
</PropertyGroup>

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

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<!-- Reduce the length of the test output dir to make it more reliable on Windows. -->
<TestsOutputName>hm</TestsOutputName>
<!-- NuGet warns about a transitive P2P to System.Text.Json that can't be pruned.
This is a false positive: https://github.com/NuGet/Home/issues/14103 -->
<NoWarn>$(NoWarn);NU1511</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand Down
3 changes: 3 additions & 0 deletions src/installer/tests/TestUtils/TestUtils.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AssemblyName>TestUtils</AssemblyName>
<PackageId>TestUtils</PackageId>
<!-- NuGet warns about a transitive P2P to System.Text.Json that can't be pruned.
This is a false positive: https://github.com/NuGet/Home/issues/14103 -->
<NoWarn>$(NoWarn);NU1511</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>$(NetCoreAppCurrent);$(NetCoreAppPrevious);$(NetCoreAppMinimum);netstandard2.0;$(NetFrameworkMinimum)</TargetFrameworks>
</PropertyGroup>
Expand All @@ -13,7 +14,11 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="$(LibrariesProjectRoot)System.Diagnostics.DiagnosticSource\ref\System.Diagnostics.DiagnosticSource.csproj" />
<ProjectReference Include="$(LibrariesProjectRoot)Microsoft.Extensions.DependencyInjection.Abstractions\ref\Microsoft.Extensions.DependencyInjection.Abstractions.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' != '$(NetCoreAppCurrent)'">
<ProjectReference Include="$(LibrariesProjectRoot)System.Diagnostics.DiagnosticSource\ref\System.Diagnostics.DiagnosticSource.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>$(NetCoreAppCurrent);$(NetCoreAppPrevious);$(NetCoreAppMinimum);netstandard2.0;$(NetFrameworkMinimum)</TargetFrameworks>
</PropertyGroup>
Expand All @@ -9,6 +10,10 @@

<ItemGroup>
<ProjectReference Include="$(LibrariesProjectRoot)Microsoft.Extensions.DependencyInjection.Abstractions\ref\Microsoft.Extensions.DependencyInjection.Abstractions.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' != '$(NetCoreAppCurrent)'">
<ProjectReference Include="$(LibrariesProjectRoot)System.Diagnostics.DiagnosticSource\ref\System.Diagnostics.DiagnosticSource.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="$(LibrariesProjectRoot)System.Text.Json\ref\System.Text.Json.csproj" />
<ProjectReference Include="$(LibrariesProjectRoot)Microsoft.Extensions.Configuration.Abstractions\ref\Microsoft.Extensions.Configuration.Abstractions.csproj" />
<ProjectReference Include="$(LibrariesProjectRoot)Microsoft.Extensions.Logging.Abstractions\ref\Microsoft.Extensions.Logging.Abstractions.csproj" />
<ProjectReference Include="$(LibrariesProjectRoot)Microsoft.Extensions.Logging\ref\Microsoft.Extensions.Logging.csproj" />
<ProjectReference Include="$(LibrariesProjectRoot)Microsoft.Extensions.Options\ref\Microsoft.Extensions.Options.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' != '$(NetCoreAppCurrent)'">
<ProjectReference Include="$(LibrariesProjectRoot)System.Text.Json\ref\System.Text.Json.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>$(NetCoreAppCurrent);$(NetCoreAppPrevious);$(NetCoreAppMinimum);netstandard2.0;$(NetFrameworkMinimum)</TargetFrameworks>
<CLSCompliant>false</CLSCompliant>
Expand All @@ -8,7 +9,7 @@
<Compile Include="System.Formats.Nrbf.cs" />
</ItemGroup>

<ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' != '$(NetCoreAppCurrent)'">
<ProjectReference Include="$(LibrariesProjectRoot)System.Reflection.Metadata\ref\System.Reflection.Metadata.csproj" />
</ItemGroup>

Expand All @@ -21,4 +22,5 @@
<Compile Include="$(CoreLibSharedDir)System\Diagnostics\CodeAnalysis\RequiresDynamicCodeAttribute.cs" />
<PackageReference Include="System.Memory" Version="$(SystemMemoryVersion)" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<Compile Include="$(CoreLibSharedDir)System\Diagnostics\CodeAnalysis\RequiresUnreferencedCodeAttribute.cs" />
</ItemGroup>

<ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' != '$(NetCoreAppCurrent)'">
<ProjectReference Include="$(LibrariesProjectRoot)System.Text.Json\ref\System.Text.Json.csproj" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ System.Security.Cryptography.Pkcs.EnvelopedCms</PackageDescription>
<None Include="@(AsnXml)" />
</ItemGroup>

<ItemGroup Condition="'$(IsPartialFacadeAssembly)' != 'true' and '$(TargetFramework)' != '$(NetCoreAppCurrent)'">
<ItemGroup Condition="'$(IsPartialFacadeAssembly)' != 'true' and !$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', '$(NetCoreAppCurrent)'))">
<ProjectReference Include="$(LibrariesProjectRoot)System.Formats.Asn1\src\System.Formats.Asn1.csproj" />
</ItemGroup>

Expand Down
19 changes: 19 additions & 0 deletions src/libraries/sfx-finish.proj
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,16 @@
<FrameworkListOutputPath>$(MicrosoftNetCoreAppRefPackDataDir)FrameworkList.xml</FrameworkListOutputPath>
<!-- Import the illink file which contains some of the logic required to illink the shared framework assemblies. -->
<ExplicitlyImportCustomILLinkTargets>true</ExplicitlyImportCustomILLinkTargets>

<PackageOverridesInputPath>$(InstallerProjectRoot)pkg\sfx\Microsoft.NETCore.App\PackageOverrides.txt</PackageOverridesInputPath>
<PackageOverridesOutputPath>$(MicrosoftNetCoreAppRefPackDataDir)PackageOverrides.txt</PackageOverridesOutputPath>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="sfx-src.proj" OutputItemType="SharedFrameworkAssembly" />
<ProjectReference Include="sfx-gen.proj" OutputItemType="SharedFrameworkAnalyzerAssembly" />

<PackageReference Include="Microsoft.DotNet.Build.Tasks.Templating" Version="$(MicrosoftDotNetBuildTasksTemplatingVersion)" />
</ItemGroup>

<Target Name="GetGenerateFrameworkListFileInputs">
Expand Down Expand Up @@ -51,6 +56,20 @@
RootAttributes="@(FrameworkListRootAttribute)" />
</Target>

<Target Name="CreatePackageOverrides"
AfterTargets="Build"
Inputs="$(PackageOverridesInputPath)"
Outputs="$(PackageOverridesOutputPath)">
<ItemGroup>
<CreatePackageOverridesTemplateProperty Include="ProductVersion=$(ProductVersion)" />
</ItemGroup>

<GenerateFileFromTemplate
TemplateFile="$(PackageOverridesInputPath)"
Properties="@(CreatePackageOverridesTemplateProperty)"
OutputPath="$(PackageOverridesOutputPath)" />
</Target>

<!-- Copy the intellisense file to the targeting pack directory. -->
<Target Name="CopyDocumentationFiles" AfterTargets="Build">
<ItemGroup>
Expand Down
Loading