C# Compiler Errors (CS0246, CS0103, CS1061) in CI
The C# compiler rejected the source. CS0246/CS0103/CS1061 mean a type, name, or member could not be resolved - usually a missing using, a missing package reference, or an API that changed in an upgraded dependency.
What this error means
Build fails with one or more error CSxxxx lines pointing at file and line. It is deterministic source code, not a transient failure. The same code fails the same way until fixed.
Services/AuthService.cs(12,17): error CS0246: The type or namespace name
'JwtSecurityTokenHandler' could not be found (are you missing a using directive
or an assembly reference?)Common causes
Missing using directive or package reference
CS0246 commonly means the namespace is not imported, or the package that provides the type was never added to the project.
API changed in an upgraded dependency
CS1061 ("no definition for X") often means a package upgrade renamed or removed a member your code still calls.
Symbol only exists under a compile constant or target
CS0103 can appear when a name is guarded by a #if constant or only exists for a different target framework than the one being built.
How to fix it
Add the missing using or package
Import the namespace and ensure the providing package is referenced.
// add at the top of the file
using System.IdentityModel.Tokens.Jwt;Fix code against the upgraded API
- For CS1061, check the dependency’s changelog for the renamed/removed member.
- Update the call site to the new API, or pin the dependency to the version your code targets.
- Rebuild and confirm the member resolves.
Build with full diagnostics
Get the complete error context to pinpoint the unresolved symbol.
dotnet build -c Release /clp:ErrorsOnly
# or more detail:
dotnet build -v normalHow to prevent it
- Pin or range-constrain dependencies so an upgrade can’t silently remove APIs.
- Run the build locally before pushing to catch compiler errors early.
- Enable nullable and analyzers to surface symbol issues during development.