-
-
Notifications
You must be signed in to change notification settings - Fork 5
Fix PAC CLI detection for VS Code extension installations #76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix PAC CLI detection for VS Code extension installations #76
Conversation
Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com>
Co-authored-by: Power-Maverick <36135520+Power-Maverick@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes PAC CLI detection issues when Power Apps CLI is installed via VS Code extension rather than globally. The enhancement implements intelligent multi-location detection that first checks for global PAC installation, then falls back to the VS Code extension location, ensuring compatibility across different installation scenarios.
- Implements multi-location PAC CLI detection with session caching for performance
- Adds overload method for custom PAC executable paths
- Maintains full backward compatibility with existing global installations
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| PCFBuilder.cs | Adds FindPacPath() method with caching and updates CheckPacVersion() to use multi-location detection |
| Commands.cs | Adds overload method Check(string pacPath) to support custom PAC executable paths |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| string[] standardCommands = new string[] { Commands.Pac.Check() }; | ||
| var standardOutput = CommandLineHelper.RunCommand(standardCommands); | ||
|
|
||
| StringHelper stringer = new StringHelper(); | ||
| PacVersionParsedDetails standardPacDetails = stringer.ParsePacVersionOutput(standardOutput); |
Copilot
AI
Sep 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The PAC checking logic is duplicated between FindPacPath() and CheckPacVersion() methods. Consider extracting this into a private helper method to reduce code duplication and improve maintainability.
| catch (Exception) | ||
| { | ||
| // If there's any error accessing the VS Code extension path, continue with standard behavior | ||
| } |
Copilot
AI
Sep 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Catching all exceptions with a generic Exception catch block is discouraged. Consider catching specific exceptions like UnauthorizedAccessException, DirectoryNotFoundException, or PathTooLongException to handle only the expected error scenarios.
| catch (Exception) | |
| { | |
| // If there's any error accessing the VS Code extension path, continue with standard behavior | |
| } | |
| catch (UnauthorizedAccessException) | |
| { | |
| // If there's any error accessing the VS Code extension path, continue with standard behavior | |
| } | |
| catch (DirectoryNotFoundException) | |
| { | |
| // If there's any error accessing the VS Code extension path, continue with standard behavior | |
| } | |
| catch (PathTooLongException) | |
| { | |
| // If there's any error accessing the VS Code extension path, continue with standard behavior | |
| } |
Resolves #34 by implementing multi-location PAC CLI detection to support Power Apps CLI installed via the Power Platform Tools VS Code extension.
Problem
When Power Apps CLI is installed through the VS Code extension (rather than globally), the tool incorrectly shows "Power Apps CLI Not Detected" even though PAC is available. This happens because the current detection logic only checks for the
paccommand in the system PATH, missing the VS Code extension installation location.Solution
Added intelligent multi-location PAC detection that checks both standard and VS Code extension locations:
paccommand (global installation)%APPDATA%\Code\User\globalStorage\microsoft-isvexptools.powerplatform-vscode\pac\tools\pac.exeImplementation Details
FindPacPath()method: Similar to the existingFindMsBuildPath()pattern, with session caching for performanceCommands.Pac.Check(): Added overload to support custom PAC executable pathsCheckPacVersion(): Now uses multi-location detection while maintaining all existing functionalityBackward Compatibility
✅ Fully backward compatible - existing global PAC installations continue to work exactly as before
✅ Graceful fallback - if VS Code detection fails, the tool falls back to original behavior
✅ No breaking changes - all existing method signatures and functionality preserved
Testing Scenarios
The fix correctly handles all installation scenarios:
Users with VS Code extension installations will now see their PAC version information instead of the "Not Detected" error, enabling full functionality of the PCF Custom Control Builder tool.
Original prompt
💡 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.