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]
What helped me is just deleting the .pubxml file(s) under the Properties > PublishProfiles folder and then recreating the publish profile again.
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.
I ran into the same problem (error) when trying to deploy my upgraded solution to AWS Lambda using:
It turned out that I'd forgotten to update my aws-lambda-tools-defaults.json file.
Adding for others in the same situation.
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 withdotnet build
4) At the end, my problem was solved and I no longer receive this error.
I had the same problem, but then I had not updated the publish profile file(.pubxml) for the right targetenvironment
And regarding to earlier answer the row
Show be removed in 2.1 version beacuse of obsolete and are included nowaday
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:
So I think you are missing the
<DotNetCliToolReferenceInclude=>
item group.