⚛ React + ASP.NET Core Guide

6. Build, publish and deploy

Publishing the server project builds the React app and bundles it with the API into one deployable app.

Publish from the command line

dotnet publish ReactWithAspNet.Server -c Release -o ./publish

The client build output (dist, created by npm run build) is included under wwwroot in the publish folder. Check the folder to confirm index.html and the assets directory are present.

Run the published app locally

cd publish
dotnet ReactWithAspNet.Server.dll

Publish with Visual Studio

  1. Right-click the server project and choose Publish.
  2. Pick a target such as Azure → Azure App Service (Windows or Linux), or Folder.
  3. Choose or create the App Service, then select Publish.

Deploy to Azure App Service with the CLI

RG=rg-reactdemo
APP=app-reactdemo-12345      # must be globally unique

az group create --name $RG --location australiaeast
az appservice plan create --resource-group $RG --name plan-reactdemo --sku B1
az webapp create --resource-group $RG --plan plan-reactdemo --name $APP --runtime "dotnet:10"

cd publish
zip -r ../site.zip .
cd ..
az webapp deploy --resource-group $RG --name $APP --src-path site.zip --type zip

Runtime strings and supported versions change, so confirm the available runtimes with az webapp list-runtimes.

Production checklist

A simple CI outline (GitHub Actions)

name: build

on:
  push:
    branches: [ main ]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - uses: actions/setup-node@v4
        with:
          node-version: 22

      - uses: actions/setup-dotnet@v4
        with:
          dotnet-version: 10.0.x

      - name: Test front end
        working-directory: reactwithaspnet.client
        run: |
          npm ci
          npm test --if-present

      - name: Publish
        run: dotnet publish ReactWithAspNet.Server -c Release -o publish