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.
This commit is contained in:
2026-04-16 15:56:15 +03:00
parent ec165d1425
commit 8e3b5ebdfc
9 changed files with 346 additions and 0 deletions
+86
View File
@@ -0,0 +1,86 @@
---
name: docker-build
description: "Build, test, publish, or pack .NET projects using the multi-stage Docker pipeline. Use when: building Docker images, running containerized tests, creating migration bundles, publishing to containers, or troubleshooting Dockerfile stages."
argument-hint: "Describe what you want to build or publish (e.g., 'publish WebApplication1 as web app')"
---
# Docker Build Skill
## When to Use
- Build and run a .NET project in Docker
- Run tests inside a container
- Create a NuGet package via Docker
- Create an EF Core migration bundle
- Troubleshoot multi-stage Docker build issues
## Prerequisites
- Docker Desktop or Docker Engine running
- Repository root as build context
## Common Workflows
### Build and run a web application
```shell
docker compose -f docker/compose.sample.yaml build sample-api \
--build-arg PUBLISHED_PROJECT=<ProjectName>
docker compose -f docker/compose.sample.yaml up sample-api
```
### Build self-contained application
```shell
docker build -f docker/Dockerfile \
--target final \
--build-arg RUNTIME_BASE=self-contained \
--build-arg PUBLISHED_PROJECT=<ProjectName> \
-t myapp .
```
### Run tests in container
```shell
docker build -f docker/Dockerfile --target test .
```
### Lint OpenAPI documents
```shell
docker build -f docker/Dockerfile --target openapi-lint .
```
### Pack NuGet packages
```shell
docker build -f docker/Dockerfile --target pack --output artifacts/nuget .
```
### Create EF Core migration bundle
```shell
docker build -f docker/Dockerfile --target migrations \
--build-arg PUBLISHED_PROJECT=<StartupProject> \
--build-arg DATABASE_PROJECT=<EFProject> \
--build-arg DBCONTEXT=<OptionalContextName> \
-t migrations .
```
## Stage Reference
See [Dockerfile](../../docker/Dockerfile) for the full multi-stage pipeline. Key stages and their targets:
| `--target` | Produces |
|------------|----------|
| `test` | Runs `dotnet test` — exits non-zero on failure |
| `openapi-lint` | Spectral lint on generated OpenAPI JSON |
| `publish` | Published app in `/app/publish` |
| `pack` | NuGet `.nupkg` files in `/app/publish` |
| `migration-bundle` | Standalone EF migration binary |
| `final` | Production runtime image |
## Troubleshooting
- **Restore failures**: Check `nuget.config` package sources and ensure `packages.lock.json` files are committed.
- **GitVersion errors**: The `gitversion` stage needs `.git/` — ensure the build context includes it.
- **Missing OpenAPI docs**: The `openapi-lint` stage only runs Spectral if `*.json` files exist in `artifacts/OpenApi/`.
+48
View File
@@ -0,0 +1,48 @@
---
name: new-library
description: 'Scaffold a new reusable .NET library with correct naming, multi-targeting, and structure. Use when: creating a new library project, adding a reusable package, setting up a shared library under src/.'
argument-hint: 'Brief description of the library purpose (e.g., "hashing utilities", "EF Core auditing")'
---
# New Library
## When to Use
- Creating a new reusable, packable library under `src/`
- Adding a shared component meant for NuGet distribution
## Naming Convention
Libraries use a `{Domain}.{Feature}` pattern. The `Kritikos.` root namespace prefix is applied automatically by `Directory.Build.props`.
| Domain prefix | When to use | Example |
|---|---|---|
| `AspNetCore.{Feature}` | Depends on `Microsoft.AspNetCore.App` | `AspNetCore.ProblemDetails` |
| `Extensions.{Feature}` | Framework-agnostic, depends only on `Microsoft.Extensions.*` | `Extensions.Hashing` |
| `EntityFrameworkCore.{Feature}` | Depends on EF Core | `EntityFrameworkCore.Auditing` |
| *(no prefix)* | Pure .NET with no framework dependency | `Primitives` |
**Always propose 24 name options** to the user and allow a custom choice.
## Multi-Targeting
Target **both current LTS versions** plus optionally **one STS version** if newer than the latest LTS:
| Scenario | Targets | Rationale |
|---|---|---|
| .NET 10 is current LTS | `net8.0;net10.0` | Skip .NET 9 (STS, superseded) |
| .NET 11 (STS) ships | `net8.0;net10.0;net11.0` | 11 > 10, include it |
| .NET 12 (LTS) ships | `net10.0;net12.0` | .NET 8 drops; 11 superseded |
Libraries with **no framework dependency** (no domain prefix) should also target `netstandard2.0`/`netstandard2.1` when APIs and dependencies allow. Framework-dependent libraries skip .NET Standard.
## Procedure
1. Ask the user for the library's purpose.
2. Propose name options using the naming table above.
3. Determine the correct multi-targeting based on current LTS/STS and framework dependencies.
4. Create the project under `src/{LibraryName}/`.
5. Do **not** specify `Version` on `PackageReference` — add versions in `Directory.Packages.props`.
6. Create a matching test project under `tests/{LibraryName}.Tests/`.
7. Add both projects to `Solution.slnx`.
8. Verify the build compiles cleanly.
@@ -0,0 +1,58 @@
---
name: new-web-api-project
description: '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/.'
argument-hint: '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`).
4. **Single target framework** — web projects target only the current LTS (no multi-targeting).
5. 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`.
6. 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.
7. Create a matching test project under `tests/{ProjectName}.Tests/`.
8. Add both projects to `Solution.slnx`.
9. 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`.
10. Verify the build compiles cleanly.
## Launch Settings Template
```json
{
"$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"
}
}
}
}
```