2

Myself as well as my coworkers all started seeing this problem sometime in the last few weeks:

Build FAILED

CSC : warning CS8032: An instance of analyzer My.Company.Generators.ReportingV2Generator cannot be created from /Users/work/dev/git/reporting-model/src/My.Company.Generators/bin/Debug/netstandard2.1/My.Company.Generators.dll : Could not load file or assembly 'Microsoft.CodeAnalysis, Version=3.10.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.. [/Users/work/dev/git/reporting-model/src/My.Team.Models.ReportingV2/My.Team.Models.ReportingV2.csproj]

/Users/work/dev/git/reporting-model/src/My.Company.Api/SmokeTests/Tests/ContentAskExpertSmokeTest.cs(7,20): error CS0234: The type or namespace name 'Models' does not exist in the namespace 'My.Team' (are you missing an assembly reference?) [/Users/work/dev/git/reporting-model/src/My.Company.Api/My.Company.Api.csproj]
... Many more of the above "type or namespace" errors
...

This happens on both macOS and Windows. It works on Linux (both on a personal machine and inside mcr.microsoft.com/dotnet/sdk:5.0.

Literally none of the source generator code / csproj has changed, it started spontaneously around two weeks ago. I can reproduce this on a commit from two months ago too, so it seems like something might have changed externally in the packages?

7
  • "Could not load file or assembly 'Microsoft.CodeAnalysis' ... The system cannot find the file specified." Commented Jul 6, 2021 at 15:12
  • Yeah, but it's there, 100%. Like I said, I checked out an old commit from two months ago, and the same problem occurs. Commented Jul 6, 2021 at 15:18
  • The dotnet restore works too, and I can see that dependency Commented Jul 6, 2021 at 15:18
  • Has something updated the cached code analysis NuGet package to a different version? Commented Jul 6, 2021 at 15:20
  • Seems unlikely given it happens on 5 different machines (mac and windows) but never on linux, and they're all pulling from the same jfrog artifactory Commented Jul 6, 2021 at 15:21

1 Answer 1

4

I found the solution for this by going to Microsoft directly.

The error on the failure case is that the generator is dependent on Microsoft.CodeAnalysis.dll version 3.10, and 3.10 only shipped in 5.0.300. It appears that your success case is using SDK 5.0.300 but the failure case is using 5.0.204.

You have two options to fix this:

If you're not using any of the features introduced in 3.10 for source generators, you can lower the Microsoft.CodeAnalysis nuget package target to 3.9 Ensure that all builds are using at least 5.0.300 version of the SDK

https://github.com/dotnet/roslyn/issues/54710

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.