Skip to content
Latchkey

C# "CS0006: Metadata file could not be found" in CI

CS0006 means the compiler was told to reference an assembly that is not on disk. In CI it usually means a referenced project failed to build first, or projects built in the wrong order, so the expected .dll was never produced. The real failure is often the upstream project's earlier error.

What this error means

Build fails with CS0006 naming a .dll path under a sibling project's bin/. The upstream project usually has its own earlier error that is the true root cause.

dotnet
error CS0006: Metadata file 'D:\a\repo\src\Core\bin\Release\net8.0\Core.dll'
could not be found

Common causes

The referenced project failed to build

The dependency project errored earlier, so its output assembly was never written and the consuming project cannot find it.

Build order or missing ProjectReference

A raw assembly reference (instead of a ProjectReference) means MSBuild does not know to build the dependency first.

How to fix it

Fix the upstream project error first

  1. Scroll up in the log to find the first failing project's real error.
  2. Resolve that error so its assembly builds.
  3. Rebuild the solution.

Use ProjectReference, not a raw HintPath

  1. Reference the dependency as a ProjectReference so MSBuild orders the build correctly.
  2. Build the whole solution rather than a single project in isolation.
.csproj
<ItemGroup>
  <ProjectReference Include="..\Core\Core.csproj" />
</ItemGroup>

How to prevent it

  • Always reference sibling projects via ProjectReference.
  • Build the solution, not individual projects, so dependencies build first.
  • Read the first error in the log, not the cascading CS0006.

Frequently asked questions

What causes ""CS0006: Metadata file ... not found""?
The dependency project errored earlier, so its output assembly was never written and the consuming project cannot find it.
How do I fix "CS0006: Metadata file ... not found"?
Fix the upstream project error first

Related guides

References

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