Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NU1107 - Version conflict detected for Microsoft.CodeAnalysis.CSharp. #147

Open
tohidazizi opened this issue Sep 20, 2024 · 2 comments
Open

Comments

@tohidazizi
Copy link

In my solution, the RazorEngineCore package is installed on a project referenced by a Web API project.

I get this error:

NU1107 Version conflict detected for Microsoft.CodeAnalysis.CSharp. Install/reference Microsoft.CodeAnalysis.CSharp 4.8.0 directly to project ICD.ChronicKidneyDisease.Api to resolve this issue.
MySolution.Api -> MySolution.HtmlGeneratorAdapter -> RazorEngineCore 2024.4.1 -> Microsoft.CodeAnalysis.CSharp (>= 4.8.0)
MySolution.Api -> Microsoft.VisualStudio.Web.CodeGeneration.Design 8.0.0 -> Microsoft.DotNet.Scaffolding.Shared 8.0.0 -> Microsoft.CodeAnalysis.CSharp.Features 4.8.0-3.final -> Microsoft.CodeAnalysis.CSharp (= 4.8.0-3.final).

I added the following line to the API project file but still got the above error.

<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.8.0" />

Any idea how to fix it?

@adoconnection
Copy link
Owner

Hi, as a quick thought, I bet it has something to do with dependentAssembly. One of your project reference newer (or older) version of Microsoft.CodeAnalysis.CSharp

checklist:

  • what project reference what version of Microsoft.CodeAnalysis
  • check web.config runtime / assemblyBinding

usually this kind of runtime / assemblyBinding helps (this one is copy-paste from google with wrong version numbers)

<dependentAssembly>
    <assemblyIdentity name="Microsoft.CodeAnalysis" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-9.9.9.9" newVersion="1.0.0.0" />
</dependentAssembly>

@leandro-almeida
Copy link

Hi, i am also facing this issue:

Severity Code Description Project File Line Suppression State
Error (active) NU1107 Version conflict detected for Microsoft.CodeAnalysis.CSharp. Install/reference Microsoft.CodeAnalysis.CSharp 4.8.0 directly to project TJPA.PagamentoPrecatorios.API to resolve this issue.
TJPA.PagamentoPrecatorios.API -> TJPA.PagamentoPrecatorios.Infrastructure.Reporting -> RazorEngineCore 2024.4.1 -> Microsoft.CodeAnalysis.CSharp (>= 4.8.0)
TJPA.PagamentoPrecatorios.API -> Microsoft.EntityFrameworkCore.Design 8.0.8 -> Microsoft.CodeAnalysis.CSharp.Workspaces 4.5.0 -> Microsoft.CodeAnalysis.CSharp (= 4.5.0). TJPA.PagamentoPrecatorios.API D:\TJPA\precatorios\api-pagamento-precatorios\src\TJPA.PagamentoPrecatorios.API\TJPA.PagamentoPrecatorios.API.csproj 1

After installing the recommended package <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.8.0" /> i still had the erros. So i looked out in my assemblies deps:

image

So i installed <PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.8.0" />, and removed <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.8.0" /> and got it to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants