Manual deployment runbook — Phase 0
When to use this runbook: a project in phase 0 (no pipeline, neither on Azure DevOps nor on GitHub Actions). A manual deployment by a person after
/hv:verifycomes out green. If your project is in phase 1 or phase 2, use the RUNBOOK.md that/hv:cicd-initgenerated.
Prerequisites
-
/hv:verifygreen locally across its 7 phases (build + diagnostics + anti-patterns + tests + security + format + diff review) - Tests with adequate coverage (≥70% line, ≥60% branch — the ecosystem's criterion)
-
appsettings.jsonwith the correctProductionvalues on the target server (do NOT overwrite it with your Development one) - Secrets in the server's
appsettings.Production.json(NEVER committed — see_hilo/DEUDA_TECNICA.mdif they are not in a secrets vault yet)
Procedure (one page at most, readable under pressure)
1. Publish the artifact locally
# From the .NET solution
dotnet publish src/<YourProject>.Web/<YourProject>.Web.csproj `
--configuration Release `
--output ./publish-output `
--no-build
Check that ./publish-output/ holds the DLLs + web.config (if IIS) + appsettings.json.
2. Pre-deploy backup on the target server
RDP into the server (DEV/DEMO/PROD). As Administrator:
$app = "<AppName>" # e.g. ScholarshipManagement
$iisPath = "C:\inetpub\wwwroot\$app"
$backupRoot = "D:\Backups\$app"
$stamp = Get-Date -Format "yyyyMMdd-HHmm"
$backupPath = Join-Path $backupRoot "backup-$stamp"
New-Item -ItemType Directory -Path $backupRoot -Force | Out-Null
Copy-Item -Path $iisPath -Destination $backupPath -Recurse -Force
Write-Host "Backup created: $backupPath"
3. Stop the app pool
$appPool = "<AppPoolName>" # e.g. ScholarshipManagementAppPool
& "$env:WINDIR\System32\inetsrv\appcmd.exe" stop apppool $appPool
Start-Sleep -Seconds 3
4. Copy the publish output into wwwroot
# Clean it (the backup from step 2 is preserved)
Remove-Item -Path "$iisPath\*" -Recurse -Force -Exclude "appsettings.Production.json","web.Production.config"
# Copy publish-output to the server (over an SMB share or by RDP copy/paste)
# Assuming the files are in C:\temp\publish-output\:
Copy-Item -Path "C:\temp\publish-output\*" -Destination $iisPath -Recurse -Force
⚠️ Do NOT overwrite the target server's
appsettings.Production.jsonorweb.Production.config. Those hold the environment's secrets.
5. Start the app pool
& "$env:WINDIR\System32\inetsrv\appcmd.exe" start apppool $appPool
Start-Sleep -Seconds 5
6. Post-deploy smoke test
# From the server (localhost) — bypass the SSL check, because the certificate is for the public FQDN, not localhost
$callback = [System.Net.ServicePointManager]::ServerCertificateValidationCallback
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = { $true }
try {
$url = "https://localhost/<YourApp>/health/live" # or equivalent
$r = Invoke-WebRequest -Uri $url -UseBasicParsing -TimeoutSec 15
if ($r.StatusCode -eq 200) {
Write-Host "OK local smoke: $url -> 200" -ForegroundColor Green
} else {
Write-Warning "local smoke: $url -> $($r.StatusCode)"
}
} finally {
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = $callback
}
Then, from the developer's browser (outside the server), open https://<env>.example.org/<YourApp>/ and confirm a 200 with the expected content.
7. If the smoke test fails — manual rollback
# Stop the pool
& "$env:WINDIR\System32\inetsrv\appcmd.exe" stop apppool $appPool
Start-Sleep -Seconds 3
# Restore from the backup
Remove-Item -Path "$iisPath\*" -Recurse -Force -Exclude "appsettings.Production.json","web.Production.config"
Copy-Item -Path "$backupPath\*" -Destination $iisPath -Recurse -Force
# Start the pool again
& "$env:WINDIR\System32\inetsrv\appcmd.exe" start apppool $appPool
# Find the cause in the logs before trying again
8. Record the deployment
Update _hilo/HISTORIAL_CAMBIOS.md:
## YYYY-MM-DD HH:MM — Manual deployment to <ENV>
- **Version**: <version or commit SHA>
- **Deployed by**: <name>
- **Backup**: D:\Backups\<App>\backup-<timestamp>
- **Smoke**: OK / FAILED (with detail if it failed)
- **Notes**: <observations>
When to move to phase 1
If you deploy by hand more than once a month, or the team grows to two or more developers, consider promoting to phase 1:
claude /hv:cicd-init # detects phase 0 and rewrites to phase 1 (idempotent)
Phase 1 adds automatically: build validation on PRs, remote dotnet test, and an artifact produced by the CI/CD platform. The deployment is still manual, but you no longer run dotnet publish locally — you download the artifact from the green build.
Anti-patterns
- ❌ Skipping
/hv:verifybecause "the change is small": most broken phase-0 deployments come from NOT running/hv:verifybefore pushing. - ❌ Not taking a pre-deploy backup: if something fails, you have no way back. The backup is MANDATORY, even for "small changes".
- ❌ Overwriting
appsettings.Production.json: it holds the environment's secrets. If you need to change something, edit the one on the server — do NOT copy yours. - ❌ Deploying to PROD without going through DEMO first: even by hand, keeping the DEV → DEMO → PROD chain helps catch bugs.
- ❌ Forgetting to record it in
HISTORIAL_CAMBIOS.md: if the app breaks in two days, nobody will know which deployment caused it.
Template of the manual deployment runbook for phase 0 — Ovillo. /hv:cicd-init adapts it with the project's own data.
Fuente: ovillo/_patron/08_CICD/RUNBOOK_DEPLOY_MANUAL_EN.md