Files
templates-dotnet/.github/skills/new-web-api-project/SKILL.md
T
akritikos 8e3b5ebdfc Adds project guidelines and conventions for Github Copilot
Introduces detailed instructions for ASP.NET API, C#, Docker, MSBuild,
testing, and library creation. These guidelines aim to standardize
development practices and improve code quality across the project.
2026-04-16 15:56:15 +03:00

2.4 KiB

name, description, argument-hint
name description argument-hint
new-web-api-project Scaffold a new ASP.NET web project (API or worker service) with correct structure, launch settings, and Docker integration. Use when: creating a new web API, adding an ASP.NET project, setting up a new web service under src/. Brief description of the web project (e.g., "REST API for user management", "background worker for email processing")

New Web Project

When to Use

  • Creating a new ASP.NET web API or worker service under src/
  • Adding a web project that will be deployed via Docker

Procedure

  1. Ask the user for the project's purpose and type (API or worker).
  2. Create the project under src/{ProjectName}/ using the appropriate SDK (Microsoft.NET.Sdk.Web or Microsoft.NET.Sdk.Worker).
  3. Single target framework — web projects target only the current LTS (no multi-targeting).
  4. Create Properties/launchSettings.json with http and https profiles:
    • Pick ports that do not conflict with existing projects — check all src/*/Properties/launchSettings.json files first.
    • Set launchBrowser: false.
    • Set ASPNETCORE_ENVIRONMENT: Development.
  5. For APIs: use Minimal APIs with OpenAPI support (Microsoft.AspNetCore.OpenApi). The OpenAPI document generation and Spectral linting are handled automatically by the build infrastructure.
  6. Create a matching test project under tests/{ProjectName}.Tests/.
  7. Add both projects to Solution.slnx.
  8. Add a compose service entry to compose.yaml (or create one from docker/compose.sample.yaml):
    • Set RUNTIME_BASE: web for APIs, RUNTIME_BASE: app for workers.
    • Set PUBLISHED_PROJECT to the project name.
    • Build context is the repo root with dockerfile: docker/Dockerfile.
  9. Verify the build compiles cleanly.

Launch Settings Template

{
  "$schema": "https://json.schemastore.org/launchsettings.json",
  "profiles": {
    "http": {
      "commandName": "Project",
      "dotnetRunMessages": true,
      "launchBrowser": false,
      "applicationUrl": "http://localhost:{HTTP_PORT}",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "https": {
      "commandName": "Project",
      "dotnetRunMessages": true,
      "launchBrowser": false,
      "applicationUrl": "https://localhost:{HTTPS_PORT};http://localhost:{HTTP_PORT}",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }
}