Version conflict detected for Microsoft.CodeAnalysis.Common. Reference the package directly from the project to resolve this issue - asp.net-core

I want to add the FluentValidation Nuget package in my asp.net core app through Nuget Package Manager.While adding I get this error:
Severity Code Description Project File Line Suppression State
Error Version conflict detected for Microsoft.CodeAnalysis.Common.
Reference the package directly from the project to resolve this issue.
Project Name -> FluentValidation.AspNetCore 7.6.103 ->
Microsoft.AspNetCore.Mvc 2.1.0 -> Microsoft.AspNetCore.Mvc.TagHelpers
2.1.0 -> Microsoft.AspNetCore.Mvc.Razor 2.1.0 -> Microsoft.CodeAnalysis.Razor 2.1.0 -> Microsoft.CodeAnalysis.Common
(>= 2.8.0) Project Name ->
Microsoft.VisualStudio.Web.CodeGeneration.Design 2.0.0 ->
Microsoft.VisualStudio.Web.CodeGenerators.Mvc 2.0.0 ->
Microsoft.VisualStudio.Web.CodeGeneration 2.0.0 ->
Microsoft.VisualStudio.Web.CodeGeneration.EntityFrameworkCore 2.0.0 ->
Microsoft.VisualStudio.Web.CodeGeneration.Core 2.0.0 ->
Microsoft.VisualStudio.Web.CodeGeneration.Templating 2.0.0 ->
Microsoft.VisualStudio.Web.CodeGeneration.Utils 2.0.0 ->
Microsoft.CodeAnalysis.CSharp.Workspaces 2.3.1 ->
Microsoft.CodeAnalysis.Workspaces.Common 2.3.1 ->
Microsoft.CodeAnalysis.Common (= 2.3.1).
How can I solve this error?

I had the same problem and was upgrading to 2.1, but for some reason I needed to manually upgrade my Microsoft.CodeAnalysis.Common package from 2.8.0 to 2.8.2
Install-Package Microsoft.CodeAnalysis.Common -Version 2.8.2

Just faced the same issue.
Unfortunately, this package refers to .net core 2.1, which is incompatible with 2.0.
Here's how I managed to resolve this issue:
- Install the 2.1 SDK from https://www.microsoft.com/net/download/windows
- Follow migration instructions from https://learn.microsoft.com/en-us/aspnet/core/migration/20_21?view=aspnetcore-2.1
Hope it helps!

If you're project is running under .NET Core 3.1 LTS
Then please install the following package into your targeted project.
Install-Package Microsoft.CodeAnalysis.Common -Version 3.6.0
And then
Install-Package Microsoft.CodeAnalysis.CSharp.Workspaces -Version 3.6.0
This will resolve your problem.

Related

Package Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation 5.0.0 is not compatible with netcoreapp3.1

I'm trying to install Nuget package Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation on a .Net core 3.1 project and getting following error.
"Package Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation 5.0.0 is not compatible with netcoreapp3.1"
I have already updated all the existing packages but no luck.
Has anyone encountered this error?
Because Package Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation 5.0.0 depends on net5.0.
You should install a version compatible with .net core 3.1,like Package Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation -Version 3.x
For me this one worked in the integrated VS terminal.
dotnet add package Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation --version 3.1.10
Installed version 3.1.10 and resolved.
PM> Install-Package Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation -Version 3.1.10

DevOps Nu1607 NU1607: Version conflict detected If I do not specify AspNetCore version

My project was building without errors but with a warning
NETSDK1071 A PackageReference to 'Microsoft.AspNetCore.App' specified a Version of 2.1.1. Specifying the version of this package is not recommended. For more information, see https://aka.ms/sdkimplicitrefs
So I edited the project and changed
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.1"/>
to
<PackageReference Include="Microsoft.AspNetCore.App" />
I pushed the code which then triggers devops to build.
However in Devops I then got the following build error
The nuget command failed with exit code(1) and error(NU1607: Version conflict detected for Microsoft.AspNetCore.Razor.Language. Reference the package directly from the project to resolve this issue.
ServerSideTests (>= 1.0.0) -> ApiForMe3 (>= 1.0.0) -> Microsoft.VisualStudio.Web.CodeGeneration.Design (>= 2.1.6) -> Microsoft.VisualStudio.Web.CodeGenerators.Mvc (>= 2.1.6) -> Microsoft.VisualStudio.Web.CodeGeneration (>= 2.1.6) -> Microsoft.VisualStudio.Web.CodeGeneration.EntityFrameworkCore (>= 2.1.6) -> Microsoft.VisualStudio.Web.CodeGeneration.Core (>= 2.1.6) -> Microsoft.VisualStudio.Web.CodeGeneration.Templating (>= 2.1.6) -> Microsoft.AspNetCore.Razor.Language (>= 2.1.1)
ServerSideTests (>= 1.0.0) -> Microsoft.AspNetCore.App (>= 2.1.0) -> Microsoft.AspNetCore.Razor.Language (>= 2.1.0).
Errors in D:\a\1\s\ServerSideTests\ServerSideTests.csproj
NU1607: Version conflict detected for Microsoft.AspNetCore.Razor.Language. Reference the package directly from the project to resolve this issue.
ServerSideTests (>= 1.0.0) -> ApiForMe3 (>= 1.0.0) -> Microsoft.VisualStudio.Web.CodeGeneration.Design (>= 2.1.6) -> Microsoft.VisualStudio.Web.CodeGenerators.Mvc (>= 2.1.6) -> Microsoft.VisualStudio.Web.CodeGeneration (>= 2.1.6) -> Microsoft.VisualStudio.Web.CodeGeneration.EntityFrameworkCore (>= 2.1.6) -> Microsoft.VisualStudio.Web.CodeGeneration.Core (>= 2.1.6) -> Microsoft.VisualStudio.Web.CodeGeneration.Templating (>= 2.1.6) -> Microsoft.AspNetCore.Razor.Language (>= 2.1.1)
ServerSideTests (>= 1.0.0) -> Microsoft.AspNetCore.App (>= 2.1.0) -> Microsoft.AspNetCore.Razor.Language (>= 2.1.0).)
Packages failed to restore
Why does the build fail in Devops but not on my local machine running VS2017 15.9.6 ?
looking up NU1607 I see
NU1107 (Previously NU1607)
Issue
Unable to resolve dependency constraints between packages.
Common causes
Packages with dependency constraints on exact versions do not allow other packages to increase the version if needed.
Example
Version conflict detected for NuGet.Versioning. Reference the package directly from the project to resolve this issue.
NuGet.Packaging 3.5.0 -> NuGet.Versioning (= 3.5.0)
NuGet.Configuration 4.0.0 -> NuGet.Versioning (= 4.0.0)
Checking the sdk versions on my machine
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional>dotnet --list-sdks
2.1.202 [C:\Program Files\dotnet\sdk]
2.1.400 [C:\Program Files\dotnet\sdk]
2.1.401 [C:\Program Files\dotnet\sdk]
2.1.402 [C:\Program Files\dotnet\sdk]
2.1.403 [C:\Program Files\dotnet\sdk]
2.1.500 [C:\Program Files\dotnet\sdk]
2.1.502 [C:\Program Files\dotnet\sdk]
2.1.503 [C:\Program Files\dotnet\sdk]
2.2.102 [C:\Program Files\dotnet\sdk]
I had a similar issue using TeamCity.
In TeamCity I changed NuGet version for NuGet Installer step.
Upgraded from Nuget.exe version 4.3 to 5.1
Problem is gone
The error I was getting:
The nuget command failed with exit code(1) and error(NU1607: Version conflict detected for Microsoft.AspNetCore.Http.Abstractions. Reference the package directly from the project to resolve this issue.
Service.Api (>= 1.0.0) -> Common.Middleware (>= 1.0.0) -> Microsoft.AspNetCore.Http.Abstractions (>= 2.2.0)
Service.Api (>= 1.0.0) -> Microsoft.AspNetCore.App (>= 2.1.0) -> Microsoft.AspNetCore.Http.Abstractions (>= 2.1.0).
Errors in d:\a\1\s\src\Service.Api\Service.Api.csproj
NU1607: Version conflict detected for Microsoft.AspNetCore.Http.Abstractions. Reference the package directly from the project to resolve this issue.
Service.Api (>= 1.0.0) -> Common.Middleware (>= 1.0.0) -> Microsoft.AspNetCore.Http.Abstractions (>= 2.2.0)
Service.Api (>= 1.0.0) -> Microsoft.AspNetCore.App (>= 2.1.0) -> Microsoft.AspNetCore.Http.Abstractions (>= 2.1.0).)
Packages failed to restore
So I made a change in .csproj file:
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
to:
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.0" />
</ItemGroup>
However, that did NOT fix the issue. (So I reverted the above changes)
Because I started getting this error:
(Output window)
>C:\Program Files\dotnet\sdk\2.2.107\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.DefaultItems.targets(153,5): warning NETSDK1071: A PackageReference to 'Microsoft.AspNetCore.App' specified a Version of `2.2.0`. Specifying the version of this package is not recommended. For more information, see https://aka.ms/sdkimplicitrefs
(Build pipeline MSBUILD task)
Services.FastService.Api.csproj : error : NETSDK1061: The project was restored using Microsoft.NETCore.App version 1.0.0, but with current settings, version 2.2.0 would be used instead. To resolve this issue, make sure the same settings are used for restore and for subsequent operations such as build or publish. Typically this issue can occur if the RuntimeIdentifier property is set during build or publish but not during restore. For more information, see https://aka.ms/dotnet-runtime-patch-selection.
Therefore I tried this:
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
</PropertyGroup>
As others have suggested, such as in this thread:
Version 2.1.0-rc1 would be used instead
But that didn't help me at all. (So I reverted that change as well.)
Eventually I realized that because MSBUILD doesn't like it when you specify a minimum version for Microsoft.AspNetCore.App, that the default minimum versions were different:
Service.Api
Common.Middleware (>= 1.0.0)
Microsoft.AspNetCore.Http.Abstractions (>= 2.1.0)
Common.Middleware
Microsoft.AspNetCore.Http.Abstractions (>= 2.2.0)
Therefore I changed the minimum version in my Common.Middleware project from '2.2.0' to '2.1.0'.
But that didn't seem to fix all my issues either!
I also tried this:
2.2.0
so:
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<RuntimeFrameworkVersion>2.2.0</RuntimeFrameworkVersion>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
</PropertyGroup>
But that didn't help either...
Finally I specified the use of NuGet 5.1.0 in my YAML build script and that fixed the project.
(So upvote to Jacob Sandh0j)
ThE FInaL SOLuTioN
YAML
- task: NuGetToolInstaller#0
inputs:
versionSpec: '5.1.0'
checkLatest: false

The name "SqlServerValueGenerationStrategy" does not exist in the current context

I am using ASP.NET Core 2.1. After I create my API project, I run following commands
Add-Migration MOBAPP -Project OVMInfrastructure
Update-Database
When I run the update-database, I get this error:
The name "SqlServerValueGenerationStrategy" does not exist in the current context
I re-installed the following Nuget packages
Microsoft.EntityFrameworkCore.SqlServer
but it's still not working.
Click here to see my error picture.
Follow Steps below:
Install Package Microsoft.EntityFrameworkCore version 2.1.0 in JSAInfrastructure
Install Package Microsoft.EntityFrameworkCore.Relational version 2.1.0 in JSAInfrastructure
Install Package Microsoft.EntityFrameworkCore.SqlServer version 2.1.0 in JSAInfrastructure
Update Microsoft.EntityFrameworkCore.SqlServer to version 2.1.0 in JSAAPI
Build your project
Result

How to update React npm package in Visual Studio 2017

I created a dotnet core 2.0 app using the React+ Redux template in VS2017. The template comes with react v15.6.1 by default, and I would like to upgrade this to v16.
I first tried going into the npm packages folder under the project dependencies list, and right clicking on react > Update Package. The update said it was completed but this however did not actually change my react version.
I then went into the package.json file and started typing in the new version and 16.2.0 came up as an intellisense option, but when I saved the file the package again did not update.
Has anyone figured out how to update the React version that comes with the template, there are a number of improvements in v16 I would like to make use of.
Here we go
After opening VS2017 go to
1) Tools -> NuGet Package Manager -> Package Manager Console
You will see Package Manager Console at the bottom pointing as PM>
2) Go to your root directory of main projects package.json file.
eg.
PM> cd D:\Myproject
3) Once you are in main directory type command below.
PM> ncu -u
After hitting this command, you will get notifications as below.
Using D:\Myproject\package.json
#types/history 4.6.0 → 4.6.2
#types/react 15.0.35 → 16.3.8
#types/react-dom 15.5.1 → 16.0.5
#types/react-hot-loader 3.0.3 → 3.0.6
#types/react-redux 4.4.45 → 5.0.16
#types/react-router 4.0.12 → 4.0.23
#types/react-router-dom 4.0.5 → 4.2.6
#types/react-router-redux 5.0.3 → 5.0.13
#types/webpack 2.2.15 → 4.1.3
#types/webpack-env 1.13.0 → 1.13.5
awesome-typescript-loader 3.2.1 → 5.0.0
bootstrap 3.3.7 → 4.1.0
css-loader 0.28.4 → 0.28.11
event-source-polyfill 0.0.9 → 0.0.12
extract-text-webpack-plugin 2.1.2 → 3.0.2
file-loader 0.11.2 → 1.1.11
history 4.6.3 → 4.7.2
jquery 3.2.1 → 3.3.1
react 15.6.1 → 16.3.1
react-dom 15.6.1 → 16.3.1
react-hot-loader 3.0.0-beta.7 → 4.0.1
react-redux 5.0.5 → 5.0.7
react-router-dom 4.1.1 → 4.2.2
redux 3.7.1 → 3.7.2
style-loader 0.18.2 → 0.20.3
typescript 2.4.1 → 2.8.1
url-loader 0.5.9 → 1.0.1
webpack 2.5.1 → 4.5.0
webpack-hot-middleware 2.18.2 → 2.22.0
webpack-merge 4.1.0 → 4.1.2
aspnet-webpack ^2.0.1 → ^2.0.3
Upgraded D:\Myproject\package.json
If you still getting older versions
Then hit this commands
npm install -g npm-check-updates
ncu -u
Ref
You have to edit package.json and change the version of react, save THEN trigger the update.

How to build ASP.NET Core 2.0 application on Windows?

Recently I installed new Visual Studio 2017 and updated SDK and Runtime to latest version 2.0 then created new ASP.NET Core 2.0 project (before all this steps I uninstall VS 2015). After all I was not able to build project, always got the same error.
Used tools:
Microsoft Visual Studio Community 2017 Version 15.3.5
ASP.NET and Web Tools 2017 15.0.30726.0
ASP.NET Core Razor Language Services 1.0
ASP.NET Template Engine 2017 15.0.30726.0
NuGet Package Manager 4.3.1
SQL Server Data Tools 15.1.61707.200
And of course I have the latest SDK and Runtime installed
_
Error:
[22:57:51]
[22:57:51]Errors in C:\path\to\project\Server\Server.csproj
[22:57:51] Package Microsoft.AspNetCore 2.0.0 is not compatible with net462 (.NETFramework,Version=v4.6.2). Package Microsoft.AspNetCore 2.0.0 supports: netstandard2.0 (.NETStandard,Version=v2.0)
[22:57:51] Package Microsoft.AspNetCore.Mvc 2.0.0 is not compatible with net462 (.NETFramework,Version=v4.6.2). Package Microsoft.AspNetCore.Mvc 2.0.0 supports: netstandard2.0 (.NETStandard,Version=v2.0)
[22:57:51] One or more packages are incompatible with .NETFramework,Version=v4.6.2.
[22:57:51] Package Microsoft.AspNetCore 2.0.0 is not compatible with net462 (.NETFramework,Version=v4.6.2) / win7-x86. Package Microsoft.AspNetCore 2.0.0 supports: netstandard2.0 (.NETStandard,Version=v2.0)
[22:57:51] Package Microsoft.AspNetCore.Mvc 2.0.0 is not compatible with net462 (.NETFramework,Version=v4.6.2) / win7-x86. Package Microsoft.AspNetCore.Mvc 2.0.0 supports: netstandard2.0 (.NETStandard,Version=v2.0)
[22:57:51] One or more packages are incompatible with .NETFramework,Version=v4.6.2 (win7-x86).
[22:57:51]
[22:57:51]Errors in C:\path\to\project\Server\Server.csproj
[22:57:51] Package Microsoft.Extensions.FileProviders.Physical 2.0.0 is not compatible with netcoreapp2.0 (.NETCoreApp,Version=v2.0). Package Microsoft.Extensions.FileProviders.Physical 2.0.0 supports: netstandard2.0 (.NETStandard,Version=v2.0)
[22:57:51] Package Microsoft.VisualStudio.Web.CodeGeneration.Contracts 2.0.0 is not compatible with netcoreapp2.0 (.NETCoreApp,Version=v2.0). Package Microsoft.VisualStudio.Web.CodeGeneration.Contracts 2.0.0 supports: netstandard2.0 (.NETStandard,Version=v2.0)
[22:57:51] One or more packages are incompatible with .NETCoreApp,Version=v2.0.
[22:57:51]Process exited with code 1