Skip to content

Packing FrameworkAssemblyReference is broken with aliased frameworks #14820

@nkolev92

Description

@nkolev92

NuGet Product Used

dotnet.exe

Product Version

10.0.300

Worked before?

Pre-NET 5 maybe

Impact

I'm unable to use this version

Repro Steps & Context

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

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>apple</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
    <LangVersion>latest</LangVersion>
  </PropertyGroup>

    <PropertyGroup>
    <SuppressDependenciesWhenPacking Condition=" '$(TargetFramework)' == 'banana' ">true</SuppressDependenciesWhenPacking>
    <TargetFrameworkIdentifier Condition=" '$(TargetFramework)' == 'apple' ">.NETFramework</TargetFrameworkIdentifier>
    <TargetFrameworkVersion Condition=" '$(TargetFramework)' == 'apple' ">v4.7.2</TargetFrameworkVersion>
  </PropertyGroup>

  <ItemGroup>
    <Reference Include="System.ComponentModel.Composition.Registration" />
    <Reference Include="System.ComponentModel.DataAnnotations" />
    <Reference Include="System.IO.Compression" />
    <Reference Include="System.Net.Http" />
    <Reference Include="System.Xml" />
  </ItemGroup>

</Project>
Restore complete (0.2s)
    info NETSDK1057: You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy
  FrameworkRef apple win-x86 failed with 1 error(s) (0.2s) → bin\Release\apple\FrameworkRef.exe
    C:\Program Files\dotnet\sdk\10.0.300-preview.0.26167.115\NuGet.Build.Tasks.Pack.targets(222,5): error NU5003: Failed to build package because of an unsupported targetFramework value on 'System.ComponentModel.Composition.Registration'.

Build failed with 1 error(s) in 0.

If you remove the framework refs, pack succeeds.

This probably isn't that big of a deal even with aliasing, since these refs are only a thing in .NET Framework, but worth fixing nonetheless.

Verbose Logs

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions