-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Source Generator - Could not load file or assembly Microsoft.CodeAnalysis on Azure Devops build agent #59945
Comments
I'm trying to get around this currently but am having no luck. I've tried separating the source generator into its own solution, generating a nuget package from it (super easy!), and referencing the nuget package. I see the same behavior of the build succeeding locally and failing with the same error under Azure Devops. Is there any eta on when this might be looked at or fixed? I'm contemplating copy-pasting the generated files' contents into actual files and removing the generator from my main solution entirely... |
I was running into this exact issue, and it turns out I was missing a dependency in my Roslyn generator project. <PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.0.1" /> Hopefully this works for you as well @tattan. edit: Actually, never mind. For some reason my pipeline passed once on a pre-release version of my code generator, but haven't been able to get it working since. |
Did a bit more digging. All my colleagues can build (even the one colleague running OSX) without issues. Just to be absolutely sure I tried building in a fresh Windows and that was successful as well. Must be something in the Azure Devops build agent I guess. Edit: Seem to have fixed it by making sure .NET 6 SDK is installed on the build agent. That also explains why I had one pipeline run that was successful yesterday, probably landed on an agent that already had it installed. Doesn't explain why it worked on a fresh Windows with only .NET 3.1 installed though, but I'll leave that mystery unsolved. @tattan: Try adding the following task to your pipeline: - task: UseDotNet@2
displayName: Use .NET SDK 6.x
inputs:
packageType: sdk
version: 6.x |
I had this exact same issue (built fine locally but not on a DevOps agent). Updating to .NET 6 did fix our issue, so I can confirm the .NET SDK does make a difference. |
@boyvanduuren thanks for sharing that fix with me! It was indeed what I needed. As far as this issue goes I think a better error message is definitely in order. Other than that I believe this issue is closed. |
Version Used:
Steps to Reproduce:
In the attached repro case there is a source generator and a test project that depends on the generator.
On an Azure Devops VM (latest agent version) using an azure pipeline:
Expected Behavior:
The build of both projects are successful both locally and on remote
Actual Behavior:
The build works in Visual Studio locally, the build fails on the Aazure Devops worker.
The generator project build succeeds, but then the project that depends on the generator fails with the warning:
I scrubbed where it has '...'
Steps I've tried:
I tried the suggested fixes from the following resources:
It appears as though I'm not the only one having an issue with source generation in either a VM or container.
https://docs.microsoft.com/en-us/answers/questions/670252/could-not-load-file-or-assembly-39microsoftcodeana.html
I do think this should be an error for code generators as it's likely more breaking than a warning leads you to believe.
simple-repro.zip
Any help or steps to try would be greatly appreciated, and please let me know if more information is required. Thanks!
The text was updated successfully, but these errors were encountered: