Closed
Description
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:
- Using this version of ASP.NET Core 'v3.0.0-preview-27122-01'
- Run this code 'dotnet new webapi'
- Modify the csproj, add an
PackageReference
orFrameworkReference
toMicrosoft.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>
-
With these arguments 'dotnet run'
-
See error(case 1 and 2)
-
When use
PackageReference
, withdotnet 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.
- When use
FrameworkReference
build successful but run failed withInvalid runtimeconfig.json
.
See there are duplicate itemsMicrosoft.AspNetCore.App
inframeworks
{
"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
}
}
}
- I see aspnet/websdk#424, remove all reference to
Microsoft.AspNetCore.App
works. But most docs only say useFrameworkReference
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: