_From @pinkfloydx33 on December 5, 2018 13:40_
I'm trying to upgrade my web application from netCore 2.1 to 2.2. I have updated the TargetFramework to netcoreapp2.2 and I receive the following errors upon restore/build/clean:
MyProduct.Web.csproj : error NU1202: Package Microsoft.AspNetCore.App 2.2.0 is not compatible with netcoreapp2.1 (.NETCoreApp,Version=v2.1). Package Microsoft.AspNetCore.App 2.2.0 supports: netcoreapp2.2 (.NETCoreApp,Version=v2.2)
MyProduct.Web.csproj : error NU1202: Package Microsoft.NETCore.App 2.2.0 is not compatible with netcoreapp2.1 (.NETCoreApp,Version=v2.1). Package Microsoft.NETCore.App 2.2.0 supports: netcoreapp2.2 (.NETCoreApp,Version=v2.2)
MyProduct.Web.csproj : error NU1202: Package Microsoft.AspNetCore.App 2.2.0 is not compatible with netcoreapp2.1 (.NETCoreApp,Version=v2.1) / win-x64. Package Microsoft.AspNetCore.App 2.2.0 supports: netcoreapp2.2 (.NETCoreApp,Version=v2.2)
MyProduct.Web.csproj : error NU1202: Package Microsoft.NETCore.App 2.2.0 is not compatible with netcoreapp2.1 (.NETCoreApp,Version=v2.1) / win-x64. Package Microsoft.NETCore.App 2.2.0 supports: netcoreapp2.2 (.NETCoreApp,Version=v2.2)
I have also done a manual clean (deleting obj/bin directories).
I can build if I change from using <TargetFramework> to <TargetFrameworks>, however I'd rather not do this and attempt to locate the underlying issue. I have two test projects in the same solution that reference the main project. I was able to migrate _them_ to netcoreapp2.2 without switching to TargetFrameworks, I would like to do the same thing for the main web app.
When I use TargetFramework (singular), Visual Studio updates the dependencies graph and removes the SDK node:

I've tried adding a global.json specifying the SDK version directly as 2.2.100 but that doesn't make any difference.
Here is my .csproj file:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<AssemblyName>MyProduct.Web</AssemblyName>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
<PreserveCompilationContext>true</PreserveCompilationContext>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<PropertyGroup>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<PackageId>$(AssemblyName)</PackageId>
<Authors>MyCompany</Authors>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
<RazorCompileOnBuild>false</RazorCompileOnBuild>
<RazorCompileOnPublish>false</RazorCompileOnPublish>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
<DefineConstants>DEBUG;TRACE</DefineConstants>
</PropertyGroup>
<ItemGroup>
<None Update="wwwroot\**\*">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MyProduct.Web.Core\MyProduct.Web.Core.csproj" />
<ProjectReference Include="..\MyProduct.Web.Api.Contracts\MyProduct.Web.Api.Contracts.csproj" />
<ProjectReference Include="..\MyProduct.Web.ViewModels\MyProduct.Web.ViewModels.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="BeginCollectionItemCore" Version="1.0.4" />
<PackageReference Include="Novell.Directory.Ldap.NETStandard" Version="2.3.5" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="2.2.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.0" PrivateAssets="All" />
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.4" />
</ItemGroup>
<ItemGroup>
<Content Update="Views\_ViewImports.cshtml">
<Pack>$(IncludeRazorContentInPack)</Pack>
</Content>
</ItemGroup>
</Project>
_Copied from original issue: dotnet/corefx#33834_
_From @karelz on December 9, 2018 8:31_
Do you have a minimal repro? Does it happen with HelloWorld?
Do you know where the netcoreapp2.1 comes from?
@nguerrera can you please help route the issue? Does not seem to be CoreFX problem ...
_From @pinkfloydx33 on December 9, 2018 10:7_
Only seems to be happening in the one project. Even tried recreating the project file from scratch. Not sure what you mean about where the 2.1 comes from? It was the previous (still installed) Sdk. If this belongs elsewhere please tell me where...I found a similar issue for the preview release of 2.2 in this repo which is why I posted here.
@pinkfloydx33, can you provide a binlog?
I was able to resolve the issue (somehow). I changed the build configuration from debug to release and it still didn't work. I attempted to _publish_ release build and it suddenly built. From that point on I could build in either release or debug (Even after a full clean).
Can mark this as closed
Same errors here. I tried to upgrade from 2.1 to 2.2
I get many errors of this kind:
error NU1202: Package Microsoft.AspNetCore.Hosting.Abstractions 2.2.0 is not compatible with netcoreapp2.2 (.NETCoreApp,Version=v2.2). Package Microsoft.AspNetCore.Hosting.Abstractions 2.2.0 does not support target frameworks.
I searched the web for hours and no solution works for me.
I'm using .NET Core SDK 2.2.103
@sven5 If you have any saved publish profiles, make sure you've updated the framework version inside them as well.
@pinkfloydx33 Thanks for your suggestion. I already updated the framework there. I'm currently recreating my web project from a new template, I found no other way.
@sven5 If you have any saved publish profiles, make sure you've updated the framework version inside them as well.
Had to do the the above but also I additionally had to update deployment scripts as my output path had changed to reflect the new version. Best to do a search for all references of netcoreapp2.1
Most helpful comment
@sven5 If you have any saved publish profiles, make sure you've updated the framework version inside them as well.