This version of Microsoft.AspNetCore.All is only c

2020-05-24 19:26发布

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]

9条回答
We Are One
2楼-- · 2020-05-24 19:33

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

查看更多
劳资没心,怎么记你
3楼-- · 2020-05-24 19:36

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.

查看更多
The star\"
4楼-- · 2020-05-24 19:37

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.

查看更多
The star\"
5楼-- · 2020-05-24 19:40

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.

查看更多
干净又极端
6楼-- · 2020-05-24 19:41

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

查看更多
疯言疯语
7楼-- · 2020-05-24 19:47

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.

查看更多
登录 后发表回答