Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 compatible with the netcoreapp2.1 target framework. Please target netcoreapp2.1 or choose a version of Microsoft.AspNetCore.All compatible with netcoreapp2.0."

It runs fine on my development machine.

Here is my project file:

<Project Sdk="Microsoft.NET.Sdk.Web"> <PropertyGroup>     <TargetFramework>netcoreapp2.1</TargetFramework>     <RunPostBuildEvent>Always</RunPostBuildEvent> </PropertyGroup> <ItemGroup>     <PackageReference Include="Microsoft.AspNetCore.All" Version="2.1.0" />     <PackageReference Include="Microsoft.AspNetCore.Cors" Version="2.1.0" />     <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.1.0" />     <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.1.0" />     <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.1.0" />     <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.4" /> </ItemGroup> </Project> 

I have seen this, but it does not seem to be the problem. I have also experimented with the prerelease 2.1 version of CodeGeneration.Tools, but I was not able to install it.

EDIT: I did install dotnet 2.1 on the server.

Here's what I see on the server:

D:\>dotnet --info Host (useful for support):   Version: 2.1.0   Commit:  caa7b7e2ba  .NET Core SDKs installed:   No SDKs were found.  .NET Core runtimes installed:   Microsoft.AspNetCore.All 2.1.0 [C:\Program Files (x86)\dotnet\shared\Microsoft.AspNetCore.All]   Microsoft.AspNetCore.App 2.1.0 [C:\Program Files (x86)\dotnet\shared\Microsoft.AspNetCore.App]   Microsoft.NETCore.App 2.0.5 [C:\Program Files (x86)\dotnet\shared\Microsoft.NETCore.App]   Microsoft.NETCore.App 2.0.6 [C:\Program Files (x86)\dotnet\shared\Microsoft.NETCore.App]   Microsoft.NETCore.App 2.1.0 [C:\Program Files (x86)\dotnet\shared\Microsoft.NETCore.App] 
like image 564
Jim S Avatar asked Jun 06 '18 23:06

Jim S


People also ask

What is Microsoft Aspnetcore App ref?

Provides a default set of APIs for building an ASP.NET Core application. Contains reference assemblies, documentation, and other design-time assets. This package is an internal implementation of the . NET Core SDK and is not meant to be used as a normal PackageReference.


2 Answers

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

like image 196
joakimja Avatar answered Sep 28 '22 08:09

joakimja


To follow on from joakimja's post, you can also update the .pubxml file via the VS2017 IDE. Right click on your project and select "publish" and then click "configure" on the "trouble shooting info" row, then go to the "settings" tab, here you can set the "Target Framework" - in fact this should have automatically updated to "netcoreapp2.1" just by opening the dialog. Click "Save" and this will update the target framework in the pubxml file. Then try publishing again.

like image 28
Matt Avatar answered Sep 28 '22 07:09

Matt