C# "CS0234: The type or namespace name X does not exist in namespace Y" in CI
CS0234 is CS0246's cousin: the outer namespace resolves, but a member of it (a sub-namespace or type) does not - usually because the assembly/package that provides that part of the namespace is not referenced. Common after a package split where types moved into a separate package.
What this error means
Build fails with CS0234 naming the missing member and its parent namespace, hinting at a missing assembly reference. Deterministic for the reference set.
Startup.cs(5,17): error CS0234: The type or namespace name 'DependencyInjection' does not
exist in the namespace 'Microsoft.Extensions' (are you missing an assembly reference?)Common causes
The package providing the sub-namespace is missing
The parent namespace comes from one assembly, but the specific sub-namespace lives in a separate package that is not referenced.
A package was split across versions
An upgrade moved types into a new package; without referencing it the sub-namespace no longer resolves.
How to fix it
Reference the package that provides the namespace
- Find which package defines the missing sub-namespace.
- Add the
PackageReference. - Restore and rebuild.
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.1" />Confirm restore ran on the runner
- Ensure
dotnet restoresucceeded before build in CI. - Check the package is not filtered out by a source mapping.
- Rebuild.
How to prevent it
- Track package splits in release notes when upgrading.
- Keep restore and build as ordered, verified CI steps.
- Use a lock file so the same packages resolve everywhere.