Skip to content
Merged
1 change: 1 addition & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
</PropertyGroup>

<ItemGroup>
<_RemovedAspNetKnownFrameworkReference Include="@(KnownFrameworkReference->WithMetadataValue('Identity', 'Microsoft.AspNetCore.App'))" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than removing this and adding it back did you consolidating the logic?

<KnownFrameworkReference Condition="'$(UseAspNetCoreSharedRuntime)' != 'true'" Remove="Microsoft.AspNetCore.App" />
<KnownFrameworkReference Remove="Microsoft.WindowsDesktop.App" />
</ItemGroup>
Expand Down
32 changes: 32 additions & 0 deletions eng/targets/ResolveReferences.targets
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,38 @@
Text="Redundant &lt;FrameworkReference&gt;. If you have an explicit item in the project file, you might be able to remove it. Some SDKs, like Microsoft.NET.Sdk.Web, add this implicitly." />
</Target>

<!--
NuGet pack reads framework references from restore assets. For affected SDK-pack projects, add a temporary
framework reference during project evaluation so that it flows into the restore assets used by pack / GenerateNuspec.
-->

<ItemGroup Condition="'$(TargetFramework)' == '$(DefaultNetCoreTargetFramework)' AND
'$(IsPackable)' == 'true' AND
'$(IsAspNetCoreApp)' != 'true' AND
'@(_FrameworkProjectReference)' != '' AND
'@(FrameworkReference->WithMetadataValue('Identity', 'Microsoft.AspNetCore.App')->Count())' == '0'">
<KnownFrameworkReference Include="@(_RemovedAspNetKnownFrameworkReference)" />
<!-- Mark as IsTransitiveFrameworkReference to exclude the pruning data: https://github.com/dotnet/sdk/issues/53106 -->
<FrameworkReference Include="Microsoft.AspNetCore.App" IsTransitiveFrameworkReference="true" DoNotResolve="true" />
</ItemGroup>

<!-- Remove the referenced AspNetCore framework before it's resolved in ResolveFrameworkReferences. This lets us use our own references. -->
<Target Name="_RemoveAspNetCoreFrameworkReference"
BeforeTargets="ResolveFrameworkReferences" >
<ItemGroup>
<FrameworkReference Remove="@(FrameworkReference->WithMetadataValue('DoNotResolve', 'true'))" />
</ItemGroup>
</Target>

<!-- Remove Transtive Microsoft.Aspnetcore.App FrameworkReference, for projects referencing the affected projects above -->
<Target Name="_RemoveAspNetCoreTransitiveFrameworkReference"
BeforeTargets="AddTransitiveFrameworkReferences"
Condition="'$(UseAspNetCoreSharedRuntime)' != 'true'" >
<ItemGroup>
<TransitiveFrameworkReference Remove="Microsoft.AspNetCore.App" />
</ItemGroup>
</Target>

<!--
This target resolves remaining Reference items to Packages, if possible. If not, they are left as Reference
items for the SDK to resolve. This executes on NuGet restore and during DesignTimeBuild. It should not run in
Expand Down
Loading