AgentSkillsCN

updating-spfx-versions

在 SharePoint Framework (SPFx) 解决方案中,于新增功能或修复 Bug 后更新版本号时,可选用此功能。

SKILL.md
--- frontmatter
name: updating-spfx-versions
description: Use when updating version numbers in SharePoint Framework (SPFx) solutions after features or bugfixes

Updating SPFx Versions

Overview

SPFx solutions have version numbers in multiple files that must stay synchronized. This skill ensures all version locations are updated correctly.

When to Use

  • After implementing a new feature (bump minor version)
  • After fixing a bug (bump patch version)
  • Before deploying a new release
  • When user asks to "increase version" or "bump version"

Version Locations

FilePropertyFormatNotes
config/package-solution.jsonsolution.versionX.Y.Z.04-part, last is always 0
config/package-solution.jsonsolution.features[].versionX.Y.Z.0Must match solution version
package.jsonversionX.Y.Z3-part semver
*.manifest.jsonversionUsually *Inherits from solution if *

Version Format

code
Major.Minor.Patch.Build
  │      │     │     └── Always 0 for SPFx
  │      │     └── Bugfixes
  │      └── New features
  └── Breaking changes

Quick Reference

Change TypeVersion BumpExample
New featureMinor2.20.0.0 → 2.21.0.0
BugfixPatch2.21.0.0 → 2.21.1.0
Breaking changeMajor2.21.0.0 → 3.0.0.0

Implementation

  1. Read current version from config/package-solution.json
  2. Determine bump type (major/minor/patch) based on change
  3. Update package-solution.json - both solution.version AND features[].version
  4. Update package.json - use 3-part format (drop the .0)
  5. Check manifest files - only update if not using * wildcard

Example Edit

json
// config/package-solution.json - update BOTH locations
"version": "2.21.0.0"  →  "version": "2.21.1.0"

// package.json - 3-part format
"version": "2.21.0"  →  "version": "2.21.1"

Common Mistakes

MistakeFix
Only updating solution.versionAlso update features[].version
Forgetting package.jsonAlways sync package.json
Using 3-part in package-solution.jsonSPFx requires 4-part: X.Y.Z.0
Using 4-part in package.jsonnpm requires 3-part: X.Y.Z
Updating manifest when it uses *Leave * alone - it inherits

Verification

After updating, run npm run build or gulp bundle to verify no errors.