Search code examples
c#visual-studiobuildmsbuildpublishing

Build is success but publish fails - This version of Microsoft.AspNetCore.All is only compatible with the netcoreapp2.2 target framework


I have a Web API project of below properties

  • .Net Core 2.2
  • Visual Studio 2017
  • version :15.7.4

Project .csproj has clearly has below settings

<PropertyGroup>
   <TargetFramework>netcoreapp2.2</TargetFramework>
 </PropertyGroup>

Build is success in Visual Studio, But when I try to publish the project I get below error

This version of Microsoft.AspNetCore.All is only compatible with the netcoreapp2.2 target framework. Please target netcoreapp2.2 or choose a version of Microsoft.AspNetCore.All compatible with netcoreapp2.1.

I am publishing using Visual Studio menu options. I am publishing to Azure app service . Publishing to File System is not showing any error.

I have nuget as follow

enter image description here

What can be the cause?


Solution

  • I just found a strange solution!

    I have created new publish profile and it worked like charm! seems like after changing project property from .Net Core 2.1 to .Net Core 2.2 we need to create a new profile always!