ASP.NET Core MVC and Minimal API development with centralized package management, MSTest, Playwright, and Claude Code infrastructure
Guide Claude Code when working with .NET full-stack projects featuring ASP.NET Core MVC, Minimal APIs, centralized package management, and comprehensive testing infrastructure.
This skill provides guidance for working with modern .NET projects (10.0+) that include:
When working with this type of project, understand the structure:
**Directory.Build.props** defines shared properties for all projects:
**Directory.Packages.props** centralizes all NuGet package versions. Project files reference packages WITHOUT version attributes.
**global.json** pins SDK version and configures the test runner (Microsoft.Testing.Platform).
```bash
dotnet build
dotnet build src/ProjectName/ProjectName.csproj
```
```bash
dotnet run --project src/Web/Web.csproj
dotnet run --project src/API/API.csproj
```
```bash
dotnet test
dotnet run --project tests/ProjectName.Tests/ProjectName.Tests.csproj
dotnet run --project tests/ProjectName.Tests.Playwright/ProjectName.Tests.Playwright.csproj
dotnet test --filter FullyQualifiedName~TestMethodName
```
After creating a Playwright test project, install browsers:
```powershell
pwsh -Command "cd tests/ProjectName.Tests.Playwright/bin/Debug/net10.0; ./playwright.ps1 install"
```
**ALWAYS** add package references WITHOUT version attributes in `.csproj` files:
```xml
<!-- CORRECT -->
<PackageReference Include="Microsoft.AspNetCore.OpenApi" />
<!-- WRONG - DO NOT include Version -->
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.0" />
```
**To add a new package:**
1. Add `<PackageVersion Include="PackageName" Version="x.y.z" />` to `Directory.Packages.props`
2. Add `<PackageReference Include="PackageName" />` to the project file
Since `ImplicitUsings` is disabled, ALL C# files must include explicit using statements:
```csharp
using System;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
```
Common namespaces for tests:
```csharp
using Microsoft.VisualStudio.TestTools.UnitTesting; // MSTest
using Microsoft.Playwright.MSTest; // Playwright
```
When creating new MSTest projects:
**CRITICAL:** Do NOT use `--test-runner` flag. The test runner is configured in `global.json`:
```bash
dotnet new mstest -o tests/NewProject --test-runner Microsoft.Testing.Platform
dotnet new mstest -o tests/NewProject
```
After creating the project, manually add to `.csproj`:
```xml
<PropertyGroup>
<EnableMSTestRunner>true</EnableMSTestRunner>
<OutputType>Exe</OutputType>
</PropertyGroup>
```
Configure parallel execution in test projects:
```csharp
[assembly: Parallelize(Scope = ExecutionScope.MethodLevel)]
```
Every pull request runs through automated validation:
1. **Authorization** - Verifies contributor authorization
2. **PR Guardrails** - Validates PR description, size, template sections
3. **Quality Checks** - Code formatting (`dotnet format`), build, tests
4. **Code Review** - Claude Code automated review (optional, requires GitHub App or token)
5. **Security Review** - GitLeaks, .NET security analyzers, NuGet vulnerability scanning, path security
6. **.NET Validation** - `.csproj` structure, CPM compliance, `global.json` validation
**Option 1: GitHub App (Recommended)**
Install via Claude Code CLI:
```bash
claude
/install-github-app
```
Or visit https://github.com/apps/claude and install manually.
**Option 2: OAuth Token**
Get token:
```bash
claude auth token
```
Add as repository secret: `CLAUDE_CODE_OAUTH_TOKEN`
Run checks locally before pushing:
```bash
dotnet format
dotnet build
dotnet test
pwsh -File .github/scripts/check-dotnet-vulnerabilities.ps1
pwsh -File .github/scripts/check-path-security.ps1
pwsh -File .github/scripts/check-csproj-structure.ps1
pwsh -File .github/scripts/check-cpm-compliance.ps1
pwsh -File .github/scripts/check-global-json.ps1
```
Automated test coverage collection with:
Automated builds for applications on push to `main`:
Pull and run:
```bash
docker pull ghcr.io/{owner}/{repo}/projectname-web:main
docker run -p 8080:8080 ghcr.io/{owner}/{repo}/projectname-web:main
```
Local build:
```bash
docker build -f src/Web/Dockerfile -t projectname-web:local .
docker run -p 8080:8080 projectname-web:local
```
Automated package publishing on tagged releases (`v*`):
```bash
git tag -a v1.0.0 -m "Release 1.0.0"
git push origin v1.0.0
```
Publishes to:
This project type includes Claude Code enhancements:
**Hooks:**
**Skills:**
- `mstest-testing-platform`
- `dotnet-centralized-packages`
- `playwright-dotnet`
- `dotnet-minimal-apis`
- `dotnet-cli-essentials`
- `aspnet-configuration`
**Agents:**
**Dev Docs System:**
Configuration in `.claude/` directory.
1. Open `Directory.Packages.props`
2. Add `<PackageVersion Include="PackageName" Version="x.y.z" />` in appropriate section
3. Open target `.csproj` file
4. Add `<PackageReference Include="PackageName" />` (NO Version attribute)
5. Run `dotnet restore` to verify
1. Create project WITHOUT `--test-runner` flag:
```bash
dotnet new mstest -o tests/NewProject.Tests
```
2. Edit `tests/NewProject.Tests/NewProject.Tests.csproj`:
```xml
<PropertyGroup>
<EnableMSTestRunner>true</EnableMSTestRunner>
<OutputType>Exe</OutputType>
</PropertyGroup>
```
3. Add to solution:
```bash
dotnet sln add tests/NewProject.Tests/NewProject.Tests.csproj
```
4. Create `MSTestSettings.cs`:
```csharp
using Microsoft.VisualStudio.TestTools.UnitTesting;
[assembly: Parallelize(Scope = ExecutionScope.MethodLevel)]
```
5. Run tests:
```bash
dotnet run --project tests/NewProject.Tests/NewProject.Tests.csproj
```
1. Create MSTest project (follow steps above)
2. Add Playwright package to `Directory.Packages.props`:
```xml
<PackageVersion Include="Microsoft.Playwright.MSTest" Version="1.x.x" />
```
3. Add reference to `.csproj`:
```xml
<PackageReference Include="Microsoft.Playwright.MSTest" />
```
4. Install browsers:
```powershell
pwsh -Command "cd tests/NewProject.Tests.Playwright/bin/Debug/net10.0; ./playwright.ps1 install"
```
5. Create test class inheriting from `PageTest`:
```csharp
using Microsoft.Playwright.MSTest;
using Microsoft.VisualStudio.TestTools.UnitTesting;
[TestClass]
public class Tests : PageTest
{
[TestMethod]
public async Task TestExample()
{
await Page.GotoAsync("https://example.com");
// assertions
}
}
```
**Using GitHub App (Recommended):**
1. Open Claude Code CLI:
```bash
claude
```
2. Run installation:
```
/install-github-app
```
3. Select repository and grant permissions
4. Create test PR to verify Step 4 executes
**Using OAuth Token:**
1. Get token:
```bash
claude auth token
```
2. Add to GitHub repository:
- Settings → Secrets and variables → Actions
- New secret: `CLAUDE_CODE_OAUTH_TOKEN`
- Paste token value
3. Create test PR to verify Step 4 executes
1. **Always run `dotnet format` before committing** - CI pipeline enforces formatting
2. **Verify tests pass locally** - Run `dotnet test` before pushing
3. **Check security locally** - Run PowerShell scripts in `.github/scripts/` before PR
4. **Never add Version to PackageReference** - Use centralized management
5. **Always add explicit using statements** - ImplicitUsings is disabled
6. **Use Microsoft.Testing.Platform** - Not legacy VSTest
7. **Configure parallel test execution** - Add `[assembly: Parallelize]` attribute
8. **Write descriptive PR descriptions** - Minimum 50 characters required
9. **Review PR validation results** - Fix issues before requesting review
10. **Tag releases with semantic versioning** - Triggers automated publishing
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/net-full-stack-development-with-claude-code/raw