.NET Deployment Issue: Ghost Dependency
Symptom
- .NET 8 app with Polly fails on deploy:
Could not load file or assembly 'Microsoft.Extensions.Http, Version=9.0.0.0'
Checks
-
Dependencies
- No preview packages in
.csproj
- Locked
Microsoft.Extensions.Http
to 8.0.0 - Local build clean → Not a package issue
- No preview packages in
-
Environment
- CI/CD fixed to .NET 8 SDK
- Cleared
~/.dotnet
and~/.nuget
- Removed caches → Environment clean
Root Cause
- Deploy script only overwrote files, never cleaned target dir
- Old
HappyNotes.Api.deps.json
misled runtime to request v9.0.0.0
Lesson Always wipe target dir before publish:
rm -rf /your/target/directory/*