freespace-freemind / STARTUP_GUIDE.md
SmartySmile's picture
Upload 45 files
0e0fe0a verified
|
Raw History Blame Contribute Delete
7.72 kB

🚀 PortWatcher Startup Guide

Quick Start (Choose Your Method)

🎯 Recommended: Interactive Menu

File: START.bat

Double-click to open a user-friendly menu with all options:

  • ✅ Run Development
  • ✅ Run Production
  • ✅ Clean & Build
  • ✅ Certificate Management
  • ✅ System Diagnostics
  • ✅ Advanced Options
START.bat

⚡ Quick Run (Simple)

File: runPortWatcher.bat

Direct run without menu (HTTPS enabled):

runPortWatcher.bat

🔧 PowerShell Alternative

dotnet run --launch-profile https

📋 START.bat Menu Options

1️⃣ Run Application (Development)

  • Cleans build artifacts
  • Builds project
  • Starts on https://localhost:7145
  • Perfect for testing locally

2️⃣ Run Application (Production)

  • Release mode build
  • Uses ports 80 (HTTP) and 443 (HTTPS)
  • Requires production certificate configured
  • May need admin privileges

3️⃣ Clean and Build

  • Removes bin/ and obj/ directories
  • Fresh build without running
  • Useful before committing code

4️⃣ Certificate Management

Submenu:

  • Check certificate status
  • Create backup
  • Manually renew certificate
  • List backup certificates
  • Restore from backup

5️⃣ System Diagnostics

Reports on:

  • .NET SDK version
  • Certificate status
  • Port availability (5293, 7145, 80, 443)
  • Project files
  • Configuration files

6️⃣ Advanced Options

  • Open certificate directory in Explorer
  • Edit configuration files
  • View application logs
  • Full system reset (keeps certificates)

7️⃣ Exit

Closes the batch script


🔐 Certificate Auto-Management

Automatic (On Startup)

  1. ✅ Checks if certificate exists
  2. ✅ Creates if missing
  3. ✅ Validates expiration
  4. ✅ Starts renewal background task

Manual (Via Batch Menu)

START.bat → Option 4 (Certificate Management)

Available Actions:

Action Effect
Check Status Shows cert info + expiration
Create Backup Backups current certificate
Manual Renew Creates new certificate
List Backups Shows all backup files
Restore Restores from backup

📁 File Structure

PortWatcher/
├── START.bat                    ← 🌟 Main Entry Point (Recommended)
├── runPortWatcher.bat           ← Quick start (simple)
├── Program.cs                   ← Updated with HTTPS config
├── appsettings.json             ← HTTP/HTTPS settings
├── appsettings.Development.json ← Dev certificate settings
├── appsettings.Production.json  ← Prod template
├── ManageCertificates.ps1       ← Used by START.bat for cert management
├── ManageCertificates.bat       ← Alternative cert management
├── Data/
│   ├── certificates/            ← Auto-created, stores certs
│   │   └── port-watcher-cert.pfx
│   └── logs/                    ← Application logs
└── README_HTTPS.md              ← Full configuration guide

⚙️ Configuration Files

Development (Default)

File: appsettings.json + appsettings.Development.json

{
  "HttpSettings": {
    "HttpPort": 5293,
    "HttpsPort": 7145
  }
}

Automatically used when running with:

  • dotnet run
  • runPortWatcher.bat
  • START.bat → Option 1

Production

File: appsettings.Production.json

{
  "HttpSettings": {
    "HttpPort": 80,
    "HttpsPort": 443
  }
}

Used when running with:

  • START.bat → Option 2
  • Environment variable: ASPNETCORE_ENVIRONMENT=Production

🛠️ Common Tasks

Start Application (Dev)

START.bat
→ Choose option 1

Check Certificate Health

START.bat
→ Choose option 4
→ Choose option 1

Renew Certificate Manually

START.bat
→ Choose option 4
→ Choose option 3
→ Confirm Y

Create Certificate Backup

START.bat
→ Choose option 4
→ Choose option 2

View System Status

START.bat
→ Choose option 5

Full System Reset

START.bat
→ Choose option 6
→ Choose option 5
→ Confirm Y

🔍 Troubleshooting

Application Won't Start

START.bat → Option 5 (Diagnostics)

Checks:

  • .NET SDK installation
  • Certificate availability
  • Port availability
  • Configuration files

.NET SDK Not Found

Install from: https://dotnet.microsoft.com/download/dotnet/8.0
Then restart START.bat

Port Already in Use

START.bat → Option 5 (Diagnostics)

Shows which ports are available.

Change ports in appsettings.json:

{
  "HttpSettings": {
    "HttpPort": 8080,      ← Change this
    "HttpsPort": 8443      ← Or this
  }
}

Certificate Issues

START.bat
→ Option 4 (Certificate Management)
→ Option 4 (List Backups)
→ Option 5 (Restore)

📊 Useful Command Examples

Via Batch Menu

START.bat

Via PowerShell

# Run development
dotnet run --launch-profile https

# Run production
$env:ASPNETCORE_ENVIRONMENT = "Production"
dotnet run

# Check certificate
.\ManageCertificates.ps1 -Status

# Renew certificate
.\ManageCertificates.ps1 -Renew -Force

Via REST API (When App Running)

# Check certificate
curl -k https://localhost:7145/api/certificatediagnostics/status

# Validate and renew
curl -k -X POST https://localhost:7145/api/certificatediagnostics/validate

# Force renewal
curl -k -X POST https://localhost:7145/api/certificatediagnostics/renew

🔒 Security Notes

Development Certificates

  • Self-signed (green warning in browser - normal)
  • Auto-created, backed up automatically
  • Valid for 365 days
  • Auto-renewals 30 days before expiry

Production Certificates

  • Use proper SSL certificate from trusted CA
  • Configure path in appsettings.Production.json
  • Set UseProductionCert: true
  • Recommended: Let's Encrypt or similar

Firewall Rules

  • Dev: Allow ports 5293 (HTTP), 7145 (HTTPS)
  • Prod: Allow ports 80 (HTTP), 443 (HTTPS)

📞 Support

Quick Help

START.bat → Option 5 (Diagnostics)

Detailed Configuration

  • Read: README_HTTPS.md
  • Read: HTTPS_CERTIFICATE_GUIDE.md

View Application Logs

START.bat → Option 6 (Advanced) → Option 4 (View Logs)

✅ First-Time Setup Checklist

  • Windows has .NET 8.0 SDK installed
  • Double-click START.bat
  • Select Option 1 (Run Development)
  • Wait for build to complete
  • Open browser: https://localhost:7145
  • Accept self-signed certificate warning
  • Application appears
  • Certificate auto-created: Data/certificates/port-watcher-cert.pfx

🎯 Key Files

File Purpose Usage
START.bat Main interactive menu Double-click to start
runPortWatcher.bat Simple quick-run Double-click for fast start
ManageCertificates.ps1 Advanced cert mgmt Called by START.bat
appsettings.json Main configuration HTTP/HTTPS ports
appsettings.Development.json Dev overrides Certificate settings
appsettings.Production.json Prod template Production ports/config

Status: ✅ Ready to Use
Last Updated: March 3, 2026
Framework: .NET 8.0 / ASP.NET Core