Overview
Building the Dev Showcase portfolio for production involves compiling the ASP.NET Core application, optimizing static assets, and preparing the deployment package. This guide covers the complete build process from development to production-ready artifacts.Prerequisites
Before building for production, ensure you have:.NET 9.0 SDK
Required to build and publish the application
Source Code
Complete project with all dependencies restored
Build Process
Restore Dependencies
Restore NuGet packages and dependencies:This reads the project file and downloads required packages.
Build in Release Mode
Build the application with Release configuration:Expected output:
Release mode enables optimizations, removes debug symbols, and prepares the application for production performance.
Build Configurations
The Dev Showcase project supports two build configurations:- Debug
- Release
Used for development with debugging symbols:Features:
- Debug symbols included
- Detailed error messages
- Exception handler disabled
- Hot reload support
Static Asset Handling
The Dev Showcase portfolio includes extensive static assets that are optimized during the build process.MapStaticAssets
FromProgram.cs:14:
- Content hashing: Files are versioned with content hashes
- Cache headers: Optimized caching for performance
- Compression: Gzip/Brotli compression enabled
Static Asset Structure
Static assets are served from the
wwwroot directory and are automatically included in the publish output.Environment Configuration
The application uses different settings based on the environment.appsettings.json
Production configuration fromappsettings.json:1-9:
appsettings.Development.json
Development-specific settings fromappsettings.Development.json:1-8:
Environment-specific settings automatically override base settings. The application detects the environment using the
ASPNETCORE_ENVIRONMENT variable.Output Optimization
Project Configuration
Fromdev-showcase.csproj:1-9:
TargetFramework: .NET 9.0 runtimeNullable: Enables nullable reference types for safer codeImplicitUsings: Reduces boilerplate with automatic using statements
Publish Options
Create optimized builds with additional options:Production Checklist
Before deploying to production, verify:Environment Settings
Environment Settings
-
ASPNETCORE_ENVIRONMENTset to “Production” - Logging configured appropriately
- Exception handler enabled
- HSTS configured
Static Assets
Static Assets
- All CSS files included
- JavaScript modules present
- Language JSON files (en.json, es.json)
- Images and icons
- Downloadable CV files
- Favicon included
Security
Security
- HTTPS redirection enabled
- Content Security Policy configured
- Sensitive data removed from configuration
- AllowedHosts configured appropriately
Performance
Performance
- Static asset compression enabled
- Response caching configured
- Output caching enabled where appropriate
- CDN configured for static assets (optional)
Troubleshooting
Build fails with missing dependencies
Build fails with missing dependencies
Run
dotnet restore to ensure all NuGet packages are installed:Static files missing in publish output
Static files missing in publish output
Verify that files are in the
wwwroot directory and check the .csproj file for any exclusions.Incorrect environment detected
Incorrect environment detected
Set the environment explicitly:
Next Steps
Hosting Your Portfolio
Learn about hosting options and deployment strategies