azure-devops-extension-tasks
azure-devops-extension-tasks copied to clipboard
Fix VSIX extension ID extraction for updateTasksId when extensionId input not provided
Problem
The updateTasksId feature couldn't derive the extension ID from VSIX-packaged extensions when the extensionId input parameter was not explicitly provided. This caused task IDs to be generated using undefined instead of the actual extension ID from the VSIX file.
Root Cause
The code was reading the extension ID from extension.vsomanifest (JSON format), but this file doesn't contain the actual extension ID - it only has contribution metadata. The real extension ID is stored in extension.vsixmanifest (XML format).
// Before (broken):
const extensionId = `${(tl.getInput("extensionId", false) || manifest.id)}${extensionTag}`;
// manifest.id was undefined from JSON manifest
Solution
Added a new getVsixExtensionId() function that:
- Detects when we're processing a VSIX directory (has both
.vsomanifestand.vsixmanifest) - Extracts the extension ID from the XML manifest using x2js parser
- Falls back gracefully to the original behavior if VSIX manifest isn't available
The extension ID resolution now follows this priority:
extensionIdinput parameter (highest priority - existing behavior)- VSIX manifest XML file (
extension.vsixmanifest) - NEW - JSON manifest file (
extension.vsomanifest) - fallback (existing behavior)
Changes
- Added x2js dependency to Common v4 and v5 packages
- Implemented
getVsixExtensionId()function in both versions - Modified
updateTaskManifests()to use VSIX extension ID when available - Added debug logging to help troubleshoot extension ID resolution
Testing
Created comprehensive tests that demonstrate:
- ✅ Old behavior: Extension ID was
undefined(broken) - ✅ New behavior: Extension ID correctly extracted as
my-awesome-extensionfrom VSIX manifest - ✅ Backward compatibility maintained when
extensionIdinput is provided - ✅ Graceful fallback when VSIX manifest not available
Impact
This fix ensures that updateTasksId works correctly for VSIX-packaged extensions without requiring users to manually specify the extensionId parameter, as the extension ID can now be automatically derived from the VSIX file itself.
Fixes #205.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.