question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NetCore2.1->2.2 Upgrade Issue; TargetFramework dropped/not recognized

See original GitHub issue

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: image

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

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
pinkfloydx33commented, Jan 22, 2019

@sven5 If you have any saved publish profiles, make sure you’ve updated the framework version inside them as well.

0reactions
TheFloydDivisionBellcommented, Feb 18, 2019

@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

Read more comments on GitHub >

github_iconTop Results From Across the Web

The TargetFramework value was not recognized. - .NET CLI
The SDK tries to parse the values provided in the project file for <TargetFramework> or <TargetFrameworks> into a well known value.
Read more >
The current .NET SDK does not support targeting . ...
I want to create a class library project with Target Framework . NET Standard 2.0.
Read more >
Target Framework .Net Core 3.0 not available
I've just updated Visual studio to 15.9.2. I've been working on a project which was using .Net core 3 preview framework. Before VS...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found