Skip to content

Prune data for netcoreapp2.1 and below contains Microsoft.NETCore.App, but it shouldn't #49917

@nkolev92

Description

@nkolev92

Describe the bug

A clear and concise description of what the bug is.

Create a new project that targets netcoreapp2.2 or below.
Enable pruning, run restore & build. Build will fail because the Microsoft.NETCore.App package is pruned.

To Reproduce

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>
    <RestoreEnablePackagePruning>true</RestoreEnablePackagePruning>
  </PropertyGroup>
</Project>
  • dotnet build

Restore will mark Microsoft.NETCore.App as IncludeAssets=none because it's prunable, and the build will f ail with missing basic types:

  E:\Code\Temp\pruningns21\obj\Debug\netcoreapp2.1\.NETCoreApp,Version=v2.1.AssemblyAttributes.cs(4,20): error CS0400: The type or namespace name 'System' could not be found in the global namespace (are you m
issing an assembly reference?) [E:\Code\Temp\pruningns21\pruningns21.csproj]
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netcoreapp2.1</TargetFramework>
    <RestoreEnablePackagePruning>true</RestoreEnablePackagePruning>
  </PropertyGroup>

  <Target Name="CleanupPruneRefs" AfterTargets="AddPrunePackageReferences">
    <ItemGroup>
      <PrunePackageReference Remove="Microsoft.NETCore.App" />
    </ItemGroup>
  </Target>
</Project>

seems to make things work, but I don't know to know enough whether the rest of the packages should remain pruned.

Now this package Microsoft.NETCore.App is implicitly reference, so there's an argument on what to do with that, but instead of letting NuGet pick, we should fix the data regardless.
Related issue: NuGet/Home#14441

Exceptions (if any)

Further technical details

  • Include the output of dotnet --info
  • The IDE (VS / VS Code/ VS4Mac) you're running on, and its version

.NET 10, P7.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions