0

I am writing a Roslyn Analyzer project for .net6.0 and migrating this from a .netstandard2.0 project of the same purpose.

It seems the latest Microsoft.CodeAnalysis NuGet dependency (a requirement for Analyzers) requires System.Collections.Immutable 6.0.0 and .net6 comes with System.Collections.Immutable 6.0.0 as a default dependency (but they appear to be different version numbers).

It appears when Roslyn tries to run the Analyzer it fails.

Has anyone seen anything similar, or have a solution to make the two different dependencies of the same version number work together?

All this code works correctly in .net standard 2.0 with an older version of System.Collections.Immutable.

CS8032 An instance of analyzer MyProject.CodeAnalysis.Analyzers.MissingAuthorizeAttribute cannot be created from C:\Git\MyProject\MyProject.CodeAnalysis\bin\Debug\net6.0\MyProject.CodeAnalysis.dll : Could not load file or assembly 'System.Collections.Immutable, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.. MyProject.Common C:\Git\MyProject\MyProject.Common\CSC 1 Active

Peter Csala
  • 17,736
  • 16
  • 35
  • 75
Cyassin
  • 1,437
  • 1
  • 15
  • 31

1 Answers1

1

I was able to resolve this.

For anyone who may see similar, the latest Microsoft.CodeAnalysis version at the time had a very small but more recent version of System.Collections.Immutable than the compiler.

  • I was using latest .net 6.0 sdk (6.0.401) and Microsoft.CodeAnalysis 4.3.0.
  • Changing it to 4.0.0 resolved the issue.
Peter Csala
  • 17,736
  • 16
  • 35
  • 75
Cyassin
  • 1,437
  • 1
  • 15
  • 31