I am getting the following error when adding an asp.net core api to an existing project I am working on.
"Version Conflict detected for Microsoft.EntityFrameworkCore.Install/reference Microsoft.EntityFrameworkCore 2.2.1 directly to project to resolve this issue"
I tried to add the Nuget package but get further version conflicts across a number of different packages and the process always fails.
At first I thought this may be an issue with my project so I started a new solution from scratch and managed to replicate the issue with a few simple steps.
Create a new solution (EFDemo)
Add a new .net Core class library to the solution called EFDemo.BL
Add the following Nuget packages to project EFDemo.BL (as I'm using an existing database for my new project)
Microsoft.EntityFrameworkCore.SqlServer (v2.2.1)
Microsoft.EntityFraneworkCore.Tools (v2.2.1)
Add a new .net core web application called EFDemo.Api and select the API project template.
Add a reference from EFDemo.BL to EFDemo.Api.
Build and see the failure.
I have reviewed the following post but its solution does not work for me as I have no reference to "Microsoft.EntityFrameworkCore" in any of my csproj files.
Version conflict detected for NuGet packages.
I have also reinstalled .net SDK, rebooted a million times and still can't understand what the issue is.
I have encountered the same error recently.
What I have done to sort this out:
Installed .Net Core 2.2 SDK
Then in my project I have changed in all .csproj files:
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
whereas before it was:
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
This helped straight away and the error dissapeared.
The answer to this is quite difficult to catalog because I made many changes while trying to figure this out.
In the end, I believe the following steps fixed my issue:
Upgrade VS to the latest version (v15.9.3)
Uninstall both .Net Core 2.1 and 2.2 SDKs (my project was using 2.1 at the time)
Install .Net Core 2.2 SDK
Convert all projects in my solution to use .Net Core 2.2 (A pain. I wish there was a Retarget All function!)
Reboot, Clean, Build and it works. Phew.
Now to do some work instead of fighting with my tools!
For me, it helped this article, it was a very simple change on the configuration, which I forgot to change:
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>
https://dotnetcoretutorials.com/2018/11/18/how-to-target-net-core-2-2/
I am not sure what package you have installed in your project.
But now days visual studio add just one nuget packages which includes all of required package for asp.net core application.
Try installing this package and remove all other package and see it that works for you.
Microsoft.AspNetCore.All
This way you will not have version conflict at least within Microsoft packages. You can then verify other external package that you might have installed which is causing problem.
I fixed this just installing .NET Core 2.2 and changing TargetFramework tag to netcoreapp2.
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>
I had followed the steps to solve my problem
Download and install the latest framework (dotnet core 2.2 in my case)
Set the project target framework to highest (dotnet core 2.2 in my case) from project properties
Clean solution
4 Rebuild solution
Update any version disputes (optional)
Rebuild and save.
Hope this helps.
Related
My main project is in .net standard 2.1
my test project is in .net core 3.1
when ever i'm trying to build the solution I'm getting the below error
NU1201: Project xxx is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1). Project yyy supports: netstandard2.1 (.NETStandard,Version=v2.1)
Can some one help me in resolving this issue
We got this error too. The reason for this is that we use our own nuget server (which was proget 4.x). Each time we need a nuget we download it from nuget.org and add it to our own nuget server. The Microsoft.IdentityModel.Protocols.OpenIdConnect 5.5.0 nuget is a signed nuget however. Out nuget server didn't support this and it complained when we added the nuget. However, the nuget did get added - only it was not signed anymore and did not contain the dll's (which is really weird). I know this sounds bizar but this is exactly what happened. We temporarily solved this by adding the official nuget feed next to our own private feed while building (as first choice). That solved our problem. I'm just posting this in th eunlikely event you have the same issue.
In the project I am currently working on, there are several projects in the solution. I had to change the target version of a particular project, which is responsible for handling particular APIs of the project, for installing certain Nuget Packages.
Now there are some .dll not found errors coming when I try to run the project.
How can I resolve this issue?
My project is based on .net framework and I am using Visual Studio 2017.
My actual Target version was .NET Framwork 4.5.1.
I had to change it to 4.6.1 since the package I was trying to install IBM.Watson.NaturalLanguageUnderstanding.v1 -Version 4.2.1 package.
Errors are like this:
Metadata file 'location\ProjectName.dll' could not be found.
My actual Target version was .NET Framwork 4.5.1. I had to change it
to 4.6.1 since the package I was trying to install
IBM.Watson.NaturalLanguageUnderstanding.v1 -Version 4.2.1 package.
I recreated the problem by attempting to install the nuget on a new console app targeting .netframework 4.6.1 and it failed
This is where problem lies, IBM Watson NaturalLanguageUnderstanding is compatible with .NETStandard 2.0 Specification which means you would need to target 4.6.1 (*2) ideally, but here is the catch (as explained here MSDN)
2 ways to solve this
Target .NetFramework 4.7.1 as recommended by the MSDN above OR
If you want to use 4.6.1 then you would need to add this to your .CSPROJ file
<PropertyGroup>
.
.
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
</PropertyGroup>
To resolve the issues, change the target frameworks of the projects that are dependent on the project for which the target framework was changed. In most cases, there won't be much problem since Microsoft gives backward compatibility. There might be some problems with third-party NuGet packages. Also, some reference errors might come when deployed.
Today, .NET Core 3.0 was released. It became available as an update in my Visual Studio for Mac, and decided to upgrade an ASP.NET Core project from .NET Core 2.2.3 to .NET Core 3.0. I thought it would be as simple as changing the Target framework in the Project Options:
and updating NuGet packages, but when trying to build the project I got the following error:
Unable to find package Microsoft.NETCore.App.Host.osx-x64 with version (= 2.2.3)
Cleaning the solution and restarting Visual Studio didn't help; is there somewhere else I have to change the .NET Core version?
It's not part of the default setup, but during the lifetime of the project I had to add a custom RuntimeFrameworkVersion setting in the .csproj file in order to make a specific package/component work. That setting was still pointing to version 2.2.3. AFAIK, there is no option to change this setting in Visual Studio itself, but if you open the project file you should be able to find it quite easily, right at the top of the file:
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<RuntimeFrameworkVersion>2.2.3</RuntimeFrameworkVersion>
<PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
<Version>1.1</Version>
</PropertyGroup>
Removing the fifth line altogether (as recommended by #MartinUllrich in the comments) or changing it to
<RuntimeFrameworkVersion>3.0.0</RuntimeFrameworkVersion>
solved the problem for me.
My project builds without any issues and can run without issues, but I cannot use dotnet ef migrations because of this strange error:
The specified framework version '2.0' could not be parsed
The specified framework 'Microsoft.NETCore.App', version '2.0' was not found.
- Check application dependencies and target a framework version installed at:
/
- Alternatively, install the framework version '2.0'.
I have latest dotnet tooling installed - SDK 2.1.4 and runtime 2.0.5.
Can anyone help with that?
I was trying to find any solutions on web but didn't find anything working...
I finally found the answer after going through some issues on GitHub.
It looks like it is an issue with dotnet CLI itself, not EF core.
If you are facing this issue, please update your .csproj file to include runtime framework version:
(at the time of writing this post I have 2.0.5 installed, but check which version you have and use correct one which you have on your machine.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<RuntimeFrameworkVersion>2.0.5</RuntimeFrameworkVersion>
</PropertyGroup>
It solves the issue properly. To me it looks like without specified version in csproj file, dotnet CLI is trying to fall back to 2.0.0 which most of us don't have on computers because of the updates.
There can also be another issue. If you are missing the Microsoft.EntityFrameworkCore.Design NuGet package, you will get the same error. So make sure you have this NuGet package referenced from the project where you want to run migrations.
Adding this to the .csproj file solved it for me, following this thread on Github:
<PropertyGroup>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
</PropertyGroup>
I'm using VS2017 on a brand new ASP.net core web application (version 1.1) and when I try to add 'api controller with actions using entity framework' I get the following error message:
There was an error running the selected code generator: 'Version for
package 'Microsoft.VisualStudio.Web.CodeGeneration.Tools' could not be
resolved.'
I've googled a bit and found a few suggestions, one of which was to add a CLI tool reference in the .csproj file, so I have added the following:
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools"
Version="1.0.1" />
</ItemGroup>
This version matched the installed version according to the NuGet package manager. However the problem still persists. Any suggestions on how to fix this please?
After a few hours of headbanging, I stumbled across this post: System could not be found Visual Studio 2017 ASP.NET Core project
I followed the advice to enable automatic check for missing packages and it finally worked!
I had the same problem, first when converting a VS2015 net core mvc web project to 2017 and then when trying to create a new core web application in 2017.
Went to Tools|NuGet Package Manager|Package Manager Settings - checked 'Allow NuGet to download missing packages' and 'Automatically check for missing packages during build in VS' and then clicked 'Clear All NuGet Cache(s)'.
Then re-built the solution - it found and loaded all the required packages and ran OK.
May not work for all cases but simple and worth a try.