Skip to content

Reference to Microsoft.AspNetCore.App not lead to an clear error when upgrade old projects to netcoreapp3.0 #4490

Closed
@yyjdelete

Description

@yyjdelete

Describe the bug

Reference to Microsoft.AspNetCore.App not lead to an clear error when upgrade old projects to netcoreapp3.0.

To Reproduce

Steps to reproduce the behavior:

  1. Using this version of ASP.NET Core 'v3.0.0-preview-27122-01'
  2. Run this code 'dotnet new webapi'
  3. Modify the csproj, add an PackageReference or FrameworkReference to Microsoft.AspNetCore.App
<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.0</TargetFramework>
    <!--<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>-->
  </PropertyGroup>


  <ItemGroup>
    <FrameworkReference Include="Microsoft.AspNetCore.App" />
    <!--<PackageReference Include="Microsoft.AspNetCore.App" />-->
  </ItemGroup>
</Project>
  1. With these arguments 'dotnet run'

  2. See error(case 1 and 2)

  3. When use PackageReference, with dotnet run in cmd failed, BUT INTERESTINGLY build&run successful in VS2019.

***.csproj : warning NU1604: 项目依赖项 Microsoft.AspNetCore.App 不具有包含下限。在依赖项版本中包含下限可确保一致的还原结果。
C:\Users\***\.nuget\packages\microsoft.aspnetcore.app\2.1.0\build\netcoreapp2.1\Microsoft.AspNetCore.App.targets(14,5): error : This version of Microsoft.AspNetCore.App is only compatible with the netcoreapp2.1 target framework. Please target netcoreapp2.1 or choose a version of Microsoft.AspNetCore.App compatible with netcoreapp3.0. [***.csproj]

The build failed. Please fix the build errors and run again.
  1. When use FrameworkReference build successful but run failed with Invalid runtimeconfig.json.
    See there are duplicate items Microsoft.AspNetCore.App in frameworks
{
  "runtimeOptions": {
    "tfm": "netcoreapp3.0",
    "frameworks": [
      {
        "name": "Microsoft.AspNetCore.App",
        "version": "3.0.0-preview-18579-0056"
      },
      {
        "name": "Microsoft.AspNetCore.App",
        "version": "3.0.0-preview-18579-0056"
      }
    ],
    "configProperties": {
      "System.GC.Server": true
    }
  }
}
  1. I see aspnet/websdk#424, remove all reference to Microsoft.AspNetCore.App works. But most docs only say use FrameworkReference instead(like Breaking changes to Microsoft.AspNetCore.App in 3.0 aspnet/Announcements#325), and don't say people should remove it when upgrade.

Expected behavior

Run successful or get an error to say what's wrong clearly in case 2.
And the result in case 1 shouldn't be inconsistent between dotnet sdk(use directly in console) and VS2019.

Screenshots

If applicable, add screenshots to help explain your problem.

Additional context

VS: 16.0.0 preview1
Add any other context about the problem here.

Include the output of dotnet --info

dotnet --info
.NET Core SDK(反映任何 global.json):
 Version:   3.0.100-preview-009812
 Commit:    e3abf6e935

运行时环境:
 OS Name:     Windows
 OS Version:  10.0.17763
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\3.0.100-preview-009812\

Host (useful for support):
  Version: 3.0.0-preview-27122-01
  Commit:  00c5c8bc40

.NET Core SDKs installed:
  2.1.2 [C:\Program Files\dotnet\sdk]
  2.1.500-preview-009335 [C:\Program Files\dotnet\sdk]
  2.1.500-preview-009404 [C:\Program Files\dotnet\sdk]
  2.1.500 [C:\Program Files\dotnet\sdk]
  2.1.600-preview-009426 [C:\Program Files\dotnet\sdk]
  2.2.100-preview3-009430 [C:\Program Files\dotnet\sdk]
  2.2.100 [C:\Program Files\dotnet\sdk]
  2.2.200-preview-009648 [C:\Program Files\dotnet\sdk]
  3.0.100-preview-009812 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.0-preview3-35497 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.0-preview3-35497 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.0.0-preview-18579-0056 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.0-preview3-27014-02 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.0.0-preview-27122-01 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.0.0-alpha-27128-4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET Core runtimes or SDKs:

Metadata

Metadata

Assignees

No one assigned

    Labels

    ✔️ Resolution: DuplicateResolved as a duplicate of another issueExternalThis is an issue in a component not contained in this repository. It is open for tracking purposes.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions