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

Microsoft.NET.ILLink.Tasks generating consolidation notice when trimming enabled #96249

Closed
mtaylorfsmb opened this issue Dec 21, 2023 · 5 comments
Assignees
Labels
area-Tools-ILLink .NET linker development as well as trimming analyzers
Milestone

Comments

@mtaylorfsmb
Copy link

mtaylorfsmb commented Dec 21, 2023

Description

I believe this package is being brought in by the .NET 8 SDK. No matter what I do any project multi-targeting .NET 8 with trimming shows that this package needs to be consolidated in the Nuget Package Manager UI for VS 2022. This is on projects that multi-target.

Reproduction Steps

  1. Create a class library that multi-targets to net472 and net6.0.
  2. Build and confirm the Nuget packages UI has no issues.
  3. Update the project to also target net8.0. (this works by itself)
  4. Now conditionally add support for trimming for NET 6+
    <PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net6.0'))">
      <ImplicitUsings>true</ImplicitUsings>
      <Nullable>disable</Nullable>
      <IsTrimmable>true</IsTrimmable>      
    </PropertyGroup>
    
  5. Now go back to the Nuget package manager UI and there are 2 packages for ILLink added and a consolidation message for the project (targeting 7.0)

Expected behavior

No consolidation issue for the ILLink package.

Actual behavior

Generates a consolidation warning in the package manager UI.

Regression?

No response

Known Workarounds

Remove trimming from project and the issue goes away.

Configuration

.NET 472, 6 and 8 with trimming
Class library

Other information

No response

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Dec 21, 2023
@ghost
Copy link

ghost commented Dec 21, 2023

Tagging subscribers to this area: @dotnet/area-infrastructure-libraries
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

I believe this package is being brought in by the .NET 8 SDK. No matter what I do any project targeting .NET 8 shows that this package needs to be consolidated in the Nuget Package Manager UI for VS 2022. This is on projects that multi-target.

Reproduction Steps

  1. Create a class library that multi-targets to net472 and net6.0.
  2. Build and confirm the Nuget packages UI has no issues.
  3. Update the project to also target net8.0. (this works by itself)
  4. Now conditionally add support for trimming for NET 6+
    <PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net6.0'))">
      <ImplicitUsings>true</ImplicitUsings>
      <Nullable>disable</Nullable>
      <IsTrimmable>true</IsTrimmable>      
    </PropertyGroup>
    
  5. Now go back to the Nuget package manager UI and there are 2 packages for ILLink added and a consolidation message for the project (targeting 7.0)

Expected behavior

No consolidation issue for the ILLink package.

Actual behavior

Generates a consolidation warning in the package manager UI.

Regression?

No response

Known Workarounds

Remove trimming from project and the issue goes away.

Configuration

.NET 472, 6 and 8 with trimming
Class library

Other information

No response

Author: mtaylorfsmb
Assignees: -
Labels:

area-Infrastructure-libraries, untriaged

Milestone: -

@ViktorHofer ViktorHofer added area-Tools-ILLink .NET linker development as well as trimming analyzers and removed area-Infrastructure-libraries labels Dec 21, 2023
@ghost
Copy link

ghost commented Dec 21, 2023

Tagging subscribers to this area: @agocke, @sbomer, @vitek-karas
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

I believe this package is being brought in by the .NET 8 SDK. No matter what I do any project multi-targeting .NET 8 with trimming shows that this package needs to be consolidated in the Nuget Package Manager UI for VS 2022. This is on projects that multi-target.

Reproduction Steps

  1. Create a class library that multi-targets to net472 and net6.0.
  2. Build and confirm the Nuget packages UI has no issues.
  3. Update the project to also target net8.0. (this works by itself)
  4. Now conditionally add support for trimming for NET 6+
    <PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net6.0'))">
      <ImplicitUsings>true</ImplicitUsings>
      <Nullable>disable</Nullable>
      <IsTrimmable>true</IsTrimmable>      
    </PropertyGroup>
    
  5. Now go back to the Nuget package manager UI and there are 2 packages for ILLink added and a consolidation message for the project (targeting 7.0)

Expected behavior

No consolidation issue for the ILLink package.

Actual behavior

Generates a consolidation warning in the package manager UI.

Regression?

No response

Known Workarounds

Remove trimming from project and the issue goes away.

Configuration

.NET 472, 6 and 8 with trimming
Class library

Other information

No response

Author: mtaylorfsmb
Assignees: -
Labels:

untriaged, area-Tools-ILLink

Milestone: -

@JDA88
Copy link

JDA88 commented Jan 30, 2024

Thank you @mtaylorfsmb!! I could not find the root cause of the consolidation notice and did not corelate it with the <IsTrimmable>true</IsTrimmable>

Setting it to false fixed the issue.

@sbomer sbomer added this to the 9.0.0 milestone Apr 25, 2024
@sbomer sbomer removed the untriaged New issue has not been triaged by the area owner label Apr 25, 2024
@sbomer
Copy link
Member

sbomer commented Aug 5, 2024

Thanks for the repro steps @mtaylorfsmb, I was able to see the same consolidation notice, though it wasn't entirely reliable. I only see it for "Manage NuGet Packages For Solution...", not "Manage NuGet Packages..." for a specific project.

As far as I can tell, the package manager UI shows this notice whenever different versions of a package are referenced across a solution - even if the different versions are referenced for different TFMs. For example, if I add the following, I get a consolidation notice for System.Text.Json:

	<ItemGroup>
		<PackageReference Condition="'$(TargetFramework)' == 'net8.0'" Include="System.Text.Json" Version="8.0.0" />
		<PackageReference Condition="'$(TargetFramework)' == 'net6.0'" Include="System.Text.Json" Version="6.0.0" />
	</ItemGroup>

The SDK effectively adds a PackageReference to Microsoft.NET.ILLink.Tasks, where the referenced version depends on the TFM, so it ends up with the same consolidation notice:

image

Interestingly, the UI is aware that the package is implicitly referenced by an SDK, but still produces a consolidation notice. I also can't select a Version in the UI - if I click that dropdown, it says "Blocked by project", which suggests this has been intentionally blocked for SDK-referenced packages.

I don't think there's anything we can do on our side to fix this - this would need to be handled in NuGet or VS, if it's not intended behavior.

@sbomer
Copy link
Member

sbomer commented Aug 5, 2024

Moved to NuGet/Home#13676

@sbomer sbomer closed this as not planned Won't fix, can't repro, duplicate, stale Aug 5, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Sep 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-Tools-ILLink .NET linker development as well as trimming analyzers
Projects
Archived in project
Development

No branches or pull requests

4 participants