Deploying an ASP.NET Core application involves preparing your app for a target environment, selecting a hosting model, and publishing the final output. ASP.NET Core supports a variety of deployment targets including Windows IIS, Linux Nginx, Docker containers, Azure App Service, and self‑contained executables.
dotnet publish -c Release -o ./publish
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
EXPOSE 80
COPY . .
ENTRYPOINT ["dotnet","MyApp.dll"]
Use the az webapp up command or deploy via GitHub Actions. See Azure deployment guide.
Publish as a self‑contained deployment and configure the web.config automatically. See Deploy to IIS.
Configure your pipeline to build and publish on each commit.
name: Build and Deploy
on:
push:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: Restore
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Publish
run: dotnet publish -c Release -o ./publish
- name: Deploy to Azure Web App
uses: azure/webapps-deploy@v2
with:
app-name: my-aspnetcore-app
publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}
package: ./publish
If you publish a self‑contained deployment, the runtime is bundled with your app and no additional installation is required.
Configure your reverse proxy (IIS, Nginx, Apache) to terminate TLS and forward requests to the Kestrel server, or use the UseHttpsRedirection middleware in Program.cs.