ASP.NET Core web app home page

Resolving the Version conflicts for a downgraded .NET Core 2.1/2.2 web app project

This post was most recently updated on September 12th, 2019.

Reading Time: 2 minutes.

I ran into compatibility issues with .NET Core 2.2 on my Azure Functions projects, so I downgraded my whole solution (an Azure Functions project, a helpers library and a web application project) to 2.1, and got rid of that particular nuisance.

This introduced a few new issues, though – namely, I started getting this error whenever trying to restore nuget packages or build the project:

NU1107	Version conflict detected for Microsoft.AspNetCore.Razor.Language. Install/reference Microsoft.AspNetCore.Razor.Language 2.2.0 directly to project [projectname] to resolve this issue. 
 [projectname] -> Microsoft.VisualStudio.Web.CodeGeneration.Design 2.2.0 -> Microsoft.VisualStudio.Web.CodeGenerators.Mvc 2.2.0 -> Microsoft.VisualStudio.Web.CodeGeneration 2.2.0 -> Microsoft.VisualStudio.Web.CodeGeneration.EntityFrameworkCore 2.2.0 -> Microsoft.VisualStudio.Web.CodeGeneration.Core 2.2.0 -> Microsoft.VisualStudio.Web.CodeGeneration.Templating 2.2.0 -> Microsoft.AspNetCore.Razor.Language (>= 2.2.0) 
 [projectname] -> Microsoft.AspNetCore.App 2.1.1 -> Microsoft.AspNetCore.Razor.Language (>= 2.1.1 && < 2.2.0).

This is apparently caused by a weirdish hardcoded dependency in .csproj file. You don’t normally run into this issue, but I suppose when you create the project with one .NET Core version (like 2.2) and then downgrade (to 2.1, in my case), you could fall into this trap.

Even though this example is for versions 2.2 and 2.1 of .NET Core, I’ve seen the same issue happen with other versions – so I don’t think the issue is exclusive to these versions of the packages.


So NuGet Package Manager is not the way to go. But you can still modify the project file directly!

The instructions that the error gives, are kind of correct – but at least for me, NuGet Package Manager would not let me install 2.2.0 version of the Microsoft.AspNetcore.Razor.Language because the project being built on 2.1, it requires a version LOWER THAN 2.2.0 of said package.

In my case, the solution to this particular instance of package version conflicts was this:

How to resolve .NET package conflicts?

  1. Modify the .csproj file of your Visual Studio project directly
    • This can be done by unloading the project, and clicking “modify the project file”
  2. Add the following lines into the package references ItemGroup
    • <PackageReference Include=”Microsoft.AspNetCore.Razor.Language” Version=”2.2.0″ />
    • <PackageReference Include=”Microsoft.Extensions.DependencyInjection” Version=”2.2.0″ />
    • <PackageReference Include=”Microsoft.Extensions.DependencyInjection.Abstractions” Version=”2.2.0″ />
  3. Reload the project
  4. Rebuild (or clean + debug)

Try running your project. If your issue was the same as mine, you should be good to go now!

Still not good to go? Maybe your issue is a bit different. Let me know in the comments section below and let’s see if we can figure it out!

Antti K. Koskela

Antti Koskela is a proud digital native nomadic millennial full stack developer (is that enough funny buzzwords? That's definitely enough funny buzzwords!), who works as a Solutions Architect for Valo Intranet, the product that will make you fall in love with your intranet. Working with the global partner network, he's responsible for the success of Valo deployments happening all around the world.

He's been a developer from 2004 (starting with PHP and Java), and he's been bending and twisting SharePoint into different shapes since MOSS. Nowadays he's not only working on SharePoint, but also on .NET projects, Azure, Office 365 and a lot of other stuff.

This is his personal professional (e.g. professional, but definitely personal) blog.

Leave a Reply

2 Comment threads
3 Thread replies
Most reacted comment
Hottest comment thread
3 Comment authors
Esteban DíezAntti K. Koskelatina Recent comment authors
newest oldest most voted
Notify of

tank you for this article


by this your solution display this
error : The element beneath element is unrecognized.

Esteban Díez

Hi Antti, I followed your instructions and added those lines into the csproj file but still coming across the same issue. Any other ideas? Thanks for your help.