dotnet / dotnet/sdk

Allow metadata on FrameworkReference such that no references are actually raised

Open
#53,106 2 comments 0 reactions 0 assignees View on GitHub
Area-NetSDK untriaged
Dominant language
C#
Stars
3.2k
Forks
1.3k
PR merge metrics
PR metrics pending

Description

I just opened https://github.com/dotnet/aspnetcore/pull/65478 to solve a problem in aspnetcore: We build our projects with ProjectReferences, but for OOB packages that have references to SharedFx-only libraries, those packages need to wind up with a FrameworkReference to Microsoft.AspNetCore.App in their .nuspec (we used to achieve this by manually re-writing the .nuspec post-build).

The new approach is to add the FrameworkReference so that restore generates a project.assets.json w/ the FrameworkReference, then hook a target before `ResolveFrameworkReferences` that removes it, so it doesn't actually get used. We also have to set `IsTransitiveFrameworkReference=true` on the FrameworkRef so that pruning warnings don't fire. It would be better if there was some metadata we could set on the FrameworkReference (like "NuspecOnly" or "DoNotRaiseAssets") so that it'd wind up in the assets file/nuspec, but its references wouldn't actually get used.

I tried "ExcludeAssets=all" but the compiler still gets references from the FrameworkReference.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.