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.
CSC : error CS8034: Unable to load Analyzer assembly ...
System.ArgumentException: Assembly with same name is already loadedCommon 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 -->
<PackageVersion Include="MyAnalyzers" Version="3.1.0" />Isolate the offending analyzer or generator
- Build with
-bland inspect the binlog to find which analyzer/generator duplicate-loaded. - Remove or pin the conflicting package so only one version is referenced.
- 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.