Skip to content
Latchkey

dotnet "Assembly with same name is already loaded" in CI

The build host tried to load two copies of the same assembly into one load context - commonly an analyzer or source generator pulled in at two versions, or a tool whose dependency duplicates one MSBuild already loaded.

What this error means

Build fails (or an analyzer/generator errors) with "Assembly with same name is already loaded". It often appears after adding an analyzer/source-generator package, or when a global tool conflicts with the SDK’s own assemblies.

dotnet build output
CSC : error CS8034: Unable to load Analyzer assembly ...
System.ArgumentException: Assembly with same name is already loaded

Common causes

Analyzer/generator duplicated at two versions

Two packages bring the same analyzer or source-generator assembly at different versions into the compiler’s load context, which refuses the duplicate.

Tool or task dependency collides with the SDK

A global/local tool or MSBuild task that bundles a copy of an assembly already loaded by the SDK can trigger the duplicate-load error.

How to fix it

Unify the duplicated package version

Pin a single version of the analyzer/generator package across the solution so only one copy loads.

Directory.Packages.props
<!-- Directory.Packages.props -->
<PackageVersion Include="MyAnalyzers" Version="3.1.0" />

Isolate the offending analyzer or generator

  1. Build with -bl and inspect the binlog to find which analyzer/generator duplicate-loaded.
  2. Remove or pin the conflicting package so only one version is referenced.
  3. Update the analyzer to a version compatible with your SDK band.

How to prevent it

  • Use central package management so analyzers/generators resolve to one version.
  • Keep analyzer and source-generator packages aligned with the SDK band.
  • Capture a binlog in CI to diagnose duplicate-load conflicts quickly.

Frequently asked questions

What causes ""Assembly with same name is already loaded""?
Two packages bring the same analyzer or source-generator assembly at different versions into the compiler’s load context, which refuses the duplicate.
How do I fix "Assembly with same name is already loaded"?
Pin a single version of the analyzer/generator package across the solution so only one copy loads.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card