Skip to content

Remove the PackageReference to Microsoft.AspNetCore.App/All from project files for netcoreapp2.x #3307

@natemcmaster

Description

@natemcmaster

Update, Jan 2019: we are not fixing for .NET Core 2, but will address this in .NET Core 3. See #3612.


Most NuGet packages provide both compilation and runtime assets. Microsoft.NETCore.App, Microsoft.AspNetCore.App, and Microsoft.AspNetCore.All effectively only provide the first - compilation references. Users must install other runtime assets to make .NET Core apps work but this is not obvious or intuitive, and not always possible: for example, Azure Web Apps, AWS, Google Cloud, etc. This violates a reasonable expectation of using a NuGet package, and has been a continual source of grief for users. Microsoft.NETCore.App had the same issues, but these were largely resolved by (1) making the PackageReference implicit based on TargetFramework and (2) pinning the package version to the lowest stable release. We should follow this pattern in the Microsoft.AspNetCore.App and .All metapackages.

Proposal

These changes are currently open for discussion. I may update this issue as we tweak this proposal.

Change 1

Update Sept. 24: this change will not be implemented.

Remove the PackageReference to Microsoft.AspNetCore.App/All from the .csproj file. Make it implicit when the RuntimeFrameworkName property is set. An ASP.NET Core web project would look like this.

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

  <PropertyGroup>
    <TargetFramework>netcoreapp2.1</TargetFramework>
    <RuntimeFrameworkName>Microsoft.AspNetCore.App</RuntimeFrameworkName>
  </PropertyGroup>

</Project>

When RuntimeFrameworkName is set, an implicit PackageReference is added to the project, but this will use the IsImplicitlyDefined property, which hides updates from NuGet UI.

The default implicit package reference will stay pinned to version AspNetCore.App 2.1.1 to maximize compatibility with the most deployment environments.

This implicit version will also use the self-contained rollforward mechanism used by Microsoft.NETCore.App today.

If users need to elevate the minimum version of the shared runtime, they can use RuntimeFrameworkVersion (which is already supported by Microsoft.NETCore.App).

  <PropertyGroup>
    <TargetFramework>netcoreapp2.1</TargetFramework>
    <RuntimeFrameworkName>Microsoft.AspNetCore.App</RuntimeFrameworkName>
    <!-- Less common, but available for users who want to ensure a minimum version. -->
    <RuntimeFrameworkVersion>2.1.789</RuntimeFrameworkVersion>
  </PropertyGroup>

Change 2

Update July 11: this piece will be implemented in 2.1.3, regardless of the other changes. We believe it helps address some issues, even if we don't land Changes 1, 3, and 4 until later. See #3316

All packages which share a dependency with Microsoft.AspNetCore.App should target 2.1.0 unless there is an important reason to force a patched version. This applies to most ASP.NET Core packages, and should also apply to third-party libraries.

We'll start by implementing this within ASP.NET Core on a repo by repo basis. Doing this from package to package within a repo is currently prohibitively expensive. We'll re-evaluate this in 2.2 or 3.0.

Change 3

Update Sept. 24: this change will not be implemented.

Issue warnings when Microsoft.AspNetCore.App/All are explicit references and encourage users to switch to the new implicit reference format. Wording might say something like:

warning: A PackageReference for 'Microsoft.AspNetCore.App' was included in your project.
We recommend removing this and adding the RuntimeFrameworkName property.

 <PropertyGroup>
    <RuntimeFrameworkName>Microsoft.AspNetCore.App</RuntimeFrameworkName>
 </PropertyGroup>

For more information, see https://aka.ms/sdkimplicitrefs

Change 4

Update Sept. 24: this change will not be implemented.

When both RuntimeFrameworkName and an explicit PackageReference are present, issue the same warning that currently exists for Microsoft.NETCore.App. It would look like this:

warning NETSDK1023: A PackageReference for 'Microsoft.AspNetCore.App' was included in your project. This package is implicitly referenced by the .NET SDK and you do not typically need to reference it from your project. For more information, see https://aka.ms/sdkimplicitrefs

Impact

Scenario: 2.1.x patch updates

Currently: users need to update the PackageReference to ensure their packages and the shared runtime stay aligned. Users must install the latest ASP.NET Core shared runtime on their servers.

Change: no modification to the .csproj file would be necessary. Users should install the latest ASP.NET Core shared runtime on their servers.

Scenario: patch updates for ASP.NET Core on .NET Framework

Currently: we cascade version udpates and re-release packages to ensure updating PackageReference hoists all transitives to latest.

Change: if there are changes in transitive dependencies which are important for users to consume, they may need to add new explicit references to get the latest patched versions.

Scenario: Minor releases

Currently: users would need to update the TargetFramework property to netcoreapp2.2 and the PackageReference to Microsoft.AspNetCore.App

Change: users only need to update the TargetFramework property to netcoreapp2.2.

cc @DamianEdwards @davidfowl @dsplaisted @nguerrera @JunTaoLuo @mlorbetske @normj

Metadata

Metadata

Assignees

No one assigned

    Labels

    ✔️ Resolution: Won't FixResolved because we decided not to change the behavior reported in this issue.cost: LWill take from 5 - 10 days to completeenhancementThis issue represents an ask for new feature or an enhancement to an existing one

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions