msvc-build

Use when compiling MSVC C++ projects, debugging build errors, or performing clean and incremental builds

18 stars

Best use case

msvc-build is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Use when compiling MSVC C++ projects, debugging build errors, or performing clean and incremental builds

Teams using msvc-build should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/msvc-build/SKILL.md --create-dirs "https://raw.githubusercontent.com/Dqz00116/skill-lib/main/msvc-build/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/msvc-build/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How msvc-build Compares

Feature / Agentmsvc-buildStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Use when compiling MSVC C++ projects, debugging build errors, or performing clean and incremental builds

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# MSVC Build Skill

## Overview

This skill provides guidance for compiling and building Microsoft Visual C++ projects using MSBuild, with intelligent error detection and resolution suggestions.

## When to Use

Use this skill when you need to:
- Compile C++ projects in Visual Studio solutions (.sln)
- Build individual project files (.vcxproj)
- Debug compilation errors
- Perform incremental or clean builds
- Compile with specific configurations (Debug/Release, Win32/x64)

## Prerequisites

- Visual Studio 2019/2022 installed
- MSBuild available in PATH or at standard location
- Project solution (.sln) or project file (.vcxproj)

## Workflow

### Step 1: Detect Build Environment

Automatically locate MSBuild:
1. Check PATH for `msbuild.exe`
2. Search standard VS2019/2022 installation paths
3. Report MSBuild version and location

### Step 2: Analyze Project Structure

Identify:
- Solution file (.sln) location
- Project dependencies
- Available configurations (Debug/Release)
- Available platforms (Win32/x64)

### Step 3: Execute Build

**Full Solution Build**:
```
MSBuild Solution.sln /p:Configuration=Debug /p:Platform=Win32 /m
```

**Single Project Build**:
```
MSBuild Solution.sln /t:ProjectName /p:Configuration=Debug /p:Platform=Win32 /m
```

**Incremental Build** (faster):
```
MSBuild Project.vcxproj /p:Configuration=Debug /p:Platform=Win32
```

**Clean Build**:
```
MSBuild Solution.sln /t:Clean
MSBuild Solution.sln /p:Configuration=Debug /p:Platform=Win32 /m
```

### Step 4: Error Analysis

Parse MSBuild output and categorize errors:

| Error Type | Pattern | Suggestion |
|------------|---------|------------|
| Missing include | `C1083: Cannot open include file` | Check include paths, verify file exists |
| Undeclared identifier | `C2065: 'X': undeclared identifier` | Check header includes, verify declaration |
| Syntax error | `C2143`, `C2061` | Check syntax, missing semicolons |
| Type undefined | `C2027: use of undefined type` | Forward declaration or missing include |
| Link error | `LNK2019`, `LNK2001` | Check library dependencies, export macros |
| Precompiled header | `C2857`, `C1853` | Ensure `#include "StableHeaders.h"` first |

## Build Commands Reference

### Basic Build

```cmd
# Debug Win32 (most common for development)
MSBuild Project.sln /p:Configuration=Debug /p:Platform=Win32 /m

# Release Win32
MSBuild Project.sln /p:Configuration=Release /p:Platform=Win32 /m

# Debug x64
MSBuild Project.sln /p:Configuration=Debug /p:Platform=x64 /m
```

### Targeted Build

```cmd
# Build specific project only
MSBuild Project.sln /t:WorldServer /p:Configuration=Debug /p:Platform=Win32

# Build multiple specific projects
MSBuild Project.sln /t:LibClient;Network;Common;WorldServer
```

### Verbosity Levels

```cmd
# Quiet - only errors
/v:q

# Minimal - errors and warnings (default)
/v:m

# Normal - standard output
/v:n

# Detailed - verbose output
/v:d

# Diagnostic - maximum detail
/v:diag
```

### Parallel Build

```cmd
# Use all processors (recommended)
/m

# Use specific number of processors
/m:4
```

## Common Issues and Solutions

### Issue 1: MSBuild Not Found

**Error**:
```
The term 'msbuild' is not recognized
```

**Solution**:
- Use Developer Command Prompt for Visual Studio
- Or provide full path to MSBuild:
  - VS2022: `C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe`
  - VS2019: `C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe`

### Issue 2: Missing Include Files

**Error**:
```
error C1083: Cannot open include file: 'Serialization/OutStream.h'
```

**Causes**:
- Missing AdditionalIncludeDirectories in .vcxproj
- Using command-line without proper environment setup
- Relative path errors in #include statements

**Solutions**:
1. Use Visual Studio IDE (handles include paths correctly)
2. Ensure Property Sheets (.props) are imported
3. Check AdditionalIncludeDirectories in project settings

### Issue 3: Precompiled Header Errors

**Error**:
```
error C2857: #include statement specified with the /Ycstdafx.h command-line option was not found
```

**Solution**:
- Ensure first line of .cpp file is `#include "StableHeaders.h"` (or project's PCH header)
- Check Precompiled Header settings in project properties

### Issue 4: Link Errors

**Error**:
```
error LNK2019: unresolved external symbol
```

**Solutions**:
- Check Additional Dependencies in Linker settings
- Ensure required .lib files are built
- Verify __declspec(dllexport/dllimport) macros for DLLs

## Integration with VS IDE

### Running from IDE

1. Open `.sln` file in Visual Studio
2. Select configuration from toolbar (Debug/Release, Win32/x64)
3. Build → Build Solution (Ctrl+Shift+B)
4. View errors in Error List window (Ctrl+\, E)

## Best Practices

1. **Always use /m for parallel builds** - Significantly faster on multi-core systems
2. **Start with minimal verbosity** - Use `/v:m`, increase only when debugging
3. **Clean build after major changes** - Delete `Debug/` or `Release/` folders
4. **Build dependencies first** - Core libs → Network → Common → Executables
5. **Check Property Sheets** - Ensure `.props` files are correctly imported

## Safety Notes

- Never modify `.vcxproj` files directly without backups
- Property Sheets (.props) changes affect multiple projects
- Precompiled header changes require full rebuild
- Be cautious with compiler warnings treated as errors

## Example Session

**User**: Compile WorldServer project in Debug Win32

**Agent**:
```
📋 Build Plan
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Solution: Project/Server/Project.sln
Target: WorldServer
Configuration: Debug | Win32
Parallel: Yes (/m)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Finding MSBuild...
✓ Found: C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe
Version: 17.14.40

Executing build...
MSBuild Project.sln /t:WorldServer /p:Configuration=Debug /p:Platform=Win32 /m /v:minimal

Build Results:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✓ LibClient.lib
✓ Network.lib
✓ Database.lib
✓ Common.lib
✓ WorldServer.exe

Build succeeded with 0 errors, 3 warnings
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```

## Limitations

- Cannot fix source code errors automatically
- Cannot modify project dependencies
- Cannot resolve missing third-party libraries
- Large solutions may require IDE for full context

## See Also

- Microsoft MSBuild documentation: https://docs.microsoft.com/visualstudio/msbuild/

Related Skills

unity-mcp

18
from Dqz00116/skill-lib

Use when controlling Unity editor via AI, automating scene operations, or programmatically generating Unity assets and scripts

ue5-umg

18
from Dqz00116/skill-lib

Use when building HUDs, menus, inventory screens, settings panels, or any widget-based interface in Unreal Engine 5. Also use when connecting C++ logic to UMG Blueprint visuals, handling gamepad or keyboard focus navigation, managing UI state, creating widget animations, or troubleshooting UMG performance issues like frame drops, hitches, or widget memory leaks.

taskmaster-skill

18
from Dqz00116/skill-lib

Use when managing complex project plans, tracking multi-phase task progress, or prioritizing development tasks

research-to-practice

18
from Dqz00116/skill-lib

Use when applying academic research to practical workflows, optimizing existing processes based on papers, or extracting actionable insights from research

requirement-clarification

18
from Dqz00116/skill-lib

Use when receiving ambiguous instructions, preparing for state-changing operations, or needing explicit user confirmation

paper-first-principles

18
from Dqz00116/skill-lib

Use when converting academic papers into engineer-friendly documentation, extracting design patterns from research, or preparing technical knowledge sharing

mvp-design

18
from Dqz00116/skill-lib

Use when designing new modules from scratch, creating minimal viable prototypes, or establishing architectural decisions before implementation

layered-first-principles-teaching

18
from Dqz00116/skill-lib

Use when explaining complex concepts to others, designing training materials, or preparing technical presentations with progressive disclosure

knowledge-base-cache

18
from Dqz00116/skill-lib

Use when managing large knowledge bases, reducing API costs, or implementing multi-tier caching for frequent queries

kimicode-vision-bridge

18
from Dqz00116/skill-lib

Use when the current Agent LLM cannot process images directly and visual analysis is needed — bridges images through KimiCode CLI print mode to a multimodal Kimi model for text description

hexo-blog-update

18
from Dqz00116/skill-lib

Use when creating, editing, or publishing Hexo blog posts

git-workflow

18
from Dqz00116/skill-lib

Use when committing code, pushing changes, or managing Git operations that require safety checks