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

10

54

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]
Restaurant answered 6/6, 2018 at 23:54 Comment(5)
Did you install the dotnet 2.1 sdk/runtime where applicable (i.e. on the server)?Federica
Yes. I'm sorry I omitted that. I did not see a 2.1 version of Entity Framework, however. Is EF included in dotnet 2.1?Restaurant
...and are you sure that you're not accidentally running under an older installed runtime? Given that your csproj is definitely 2.1, it seems to me that the runtime is the only variable here.Federica
I have added the result from a dotnet --info. Multiple versions are installed. However, I never get as far as running anything. Visual Studio gives the message above when I try to publish to the server.Restaurant
As suggested by learn.microsoft.com/en-us/aspnet/core/fundamentals/…, I removed AspNetCore.All and replaced it by AspNetCore.App. However, I still get the xame message.Restaurant
M
86

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

Metzger answered 7/6, 2018 at 10:25 Comment(2)
Changing the .pubxml file fixed the problem. Thank you so much!Restaurant
Removing the Microsoft.EntityFrameworkCore.Tools.DotNet fixed it for me. Thanks!Conveyor
D
23

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.

Darr answered 3/9, 2018 at 10:10 Comment(2)
Very confusing. The fact that it automatically updates it to the correct version only makes it even more confusing. I thought: "Oh, but it is set correctly already!" Thank you for pointing this out! +1Sabian
Thanks. Perfect. Worked for the same issue with 2.2Picul
G
7
  1. You possibly need to do clean on the project first.
  2. Right click on the Project File in Visual Studio.
  3. Click the properties select the Application -> Target Framework drop down and choose the version of .Net Core Framework you are wanting to use.
  4. Rebuild your solution.
Goodygoody answered 25/9, 2018 at 18:53 Comment(1)
I also had to edit my publish config, do nothing, save, and then publishing worked. Looks like publish profiles have a pointer to the target runtime that isn't auto-updated.Kory
T
5

What helped me is just deleting the .pubxml file(s) under the Properties > PublishProfiles folder and then recreating the publish profile again.

Tammy answered 30/7, 2018 at 19:16 Comment(0)
O
4

enter image description hereI 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.

Orford answered 23/4, 2019 at 15:23 Comment(0)
V
3

I ran into the same problem (error) when trying to deploy my upgraded solution to AWS Lambda using:

dotnet lambda deploy-serverless

It turned out that I'd forgotten to update my aws-lambda-tools-defaults.json file.

"framework"     : "netcoreapp2.1",

Adding for others in the same situation.

Veron answered 23/11, 2018 at 12:58 Comment(0)
T
2

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.

Tapes answered 7/6, 2018 at 5:40 Comment(2)
Thank your for your help. I did start with 2.0. I'm not sure I understand. Are you saying (in part) that I should manually downgrade (by hand editing) and then upgrade using NuGet? I'm trying to upgrade because of a problem in 2.0.Restaurant
Guess it was the pub.xml file. Let me know if you want me to take this answer down. Was gonna leave it if some one wanted a quick fix to downgrade.Tapes
C
2

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.

Celiotomy answered 8/7, 2019 at 15:55 Comment(1)
i tried other solutions, but only this one worked for me.Luxuriance
H
2

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>
Hunchback answered 31/8, 2019 at 9:44 Comment(0)
G
2

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

Galantine answered 3/6, 2020 at 0:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.