This version of Microsoft.AspNetCore.All is only compatible with the netcoreapp2.1 target framework

后端 未结 10 1188
无人共我
无人共我 2021-02-04 23:24

When I try to publish my application to the web server after upgrading to .NET Core 2.1 from 2.0, I get this message: \"This version of Microsoft.AspNetCore.All is only compatib

相关标签:
10条回答
  • 2021-02-05 00:02

    Im guessing you pulled all the 2.1.x upgrades but initially started your project in 2.0.x. I just hand edit the cspoj file by downgrading back down and adding:

    <Project Sdk="Microsoft.NET.Sdk.Web">
    <PropertyGroup>
        <TargetFramework>netcoreapp2</TargetFramework>
    
    </PropertyGroup>
    
    
    <ItemGroup>             
    <PackageReference Include=
    "Microsoft.AspNetCore.All" Version="2.0.3" />
    <PackageReference Include=
    "Microsoft.AspNetCore.Cors" Version="2.0.3" />                  
    <PackageReference Include=
    "Microsoft.EntityFrameworkCore.SqlServer" Version="2.0.3" />                            
    <PackageReference Include=
    "Microsoft.EntityFrameworkCore.Tools" Version="2.0.3" PrivateAssets="All" />       
    <PackageReference Include=
    "Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.4" PrivateAssets="All" />
    </ItemGroup>  
    
    
    <ItemGroup>                      
    <DotNetCliToolReferenceInclude=
        "Microsoft.EntityFrameworkCore.Tools.DotNet"Version="2.0.3" />   
    <DotNetCliToolReferenceInclude=
        "Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.4" /> 
    <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.3" />       
    </ItemGroup>
    

    So I think you are missing the <DotNetCliToolReferenceInclude=> item group.

    0 讨论(0)
  • 2021-02-05 00:02

    I deleted my obj folder inside project which had json files pointing to 2.2 version from previous build.

    0 讨论(0)
  • 2021-02-05 00:06

    Sorry for late reply,

    I got this error now and found the solution.

    We need to change TargetFramework version in PublishProfiles to netcoreapp2.2

    <_SavePWD>True</_SavePWD>
    <_DestinationType>AzureWebSite</_DestinationType>
    <TargetFramework>netcoreapp2.2</TargetFramework>
    <SelfContained>false</SelfContained>
    <_IsPortable>true</_IsPortable>
    
    0 讨论(0)
  • 2021-02-05 00:07

    I was stuck with this issue for about 3 hours. Eventually, this error came when I added a Nuget package Microsoft.VisualStudio.Web.CodeGeneration.Design. This is what I did to solve this issue:

    1) Deleted bin folder of my .net core project

    2) Explicitly added the dotnet version to TargetFramework and PackageReference to 2.1.0. You can try adding what is best for your project and dotnet version.

    3) I restored the project with dotnet restore and then build with dotnet build

    4) At the end, my problem was solved and I no longer receive this error.

    0 讨论(0)
  • 2021-02-05 00:11

    I tried most of the suggestions I could find but what ended up fixing the issue was deleting the Microsoft.AspNetCore.All package from here:

    %userprofile%.nuget\packages\microsoft.aspnetcore.all\2.1.5\build\netcoreapp2.1\

    The next build restored the correct version.

    0 讨论(0)
  • 2021-02-05 00:18

    I had the same problem, but then I had not updated the publish profile file(.pubxml) for the right targetenvironment

    < TargetFramework>netcoreapp2.1< /TargetFramework>
    

    And regarding to earlier answer the row

    < DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.1" />
    

    Show be removed in 2.1 version beacuse of obsolete and are included nowaday

    0 讨论(0)
提交回复
热议问题