- 
                Notifications
    You must be signed in to change notification settings 
- Fork 727
Support optional components #8703
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
Support optional components #8703
Conversation
Co-authored-by: JoeRobich <611219+JoeRobich@users.noreply.github.com>
Co-authored-by: JoeRobich <611219+JoeRobich@users.noreply.github.com>
| @copilot Update  | 
Co-authored-by: JoeRobich <611219+JoeRobich@users.noreply.github.com>
Co-authored-by: JoeRobich <611219+JoeRobich@users.noreply.github.com>
| 
 Updated  Commit: 8def695 
 Updated  Commit: 9c0d446 | 
Co-authored-by: JoeRobich <611219+JoeRobich@users.noreply.github.com>
Co-authored-by: JoeRobich <611219+JoeRobich@users.noreply.github.com>
        
          
                test/omnisharp/omnisharpUnitTests/packages/downloadAndInstallPackages.test.ts
              
                Outdated
          
            Show resolved
            Hide resolved
        
      Co-authored-by: JoeRobich <611219+JoeRobich@users.noreply.github.com>
…operty Co-authored-by: JoeRobich <611219+JoeRobich@users.noreply.github.com>
        
          
                tasks/offlinePackagingTasks.ts
              
                Outdated
          
        
      | const provider = () => new NetworkSettings('', true); | ||
| if (!(await downloadAndInstallPackages(packagesToInstall, provider, eventStream, isValidDownload, token))) { | ||
| if ( | ||
| !(await downloadAndInstallPackages(packagesToInstall, provider, eventStream, isValidDownload, undefined, token)) | 
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.
This should probably check that all results were successful
Added support for marking runtime dependencies as optional in package.json. When a runtime dependency is marked with
"isOptional": true, the extension will log failure events, send telemetry, and continue with activation instead of stopping.Problem
Previously, if any runtime dependency failed to download during extension activation, the entire activation process would stop. This caused the extension to be unusable even when the failed dependency was not critical for core functionality. Additionally, there was no telemetry tracking for package installation failures, and the extension would throw errors when trying to load optional components that weren't installed.
Solution
Added an
isOptionalboolean field to the package interface. When a package is marked as optional ("isOptional": true), download or installation failures are logged but don't prevent extension activation from completing. Additionally, telemetry events are now sent for all package installation failures across both the main extension and OmniSharp components. Component loading infrastructure was updated to handle missing optional components gracefully with warning logs.Changes Made
isOptional?: booleanfieldisOptionalproperty from package definitionsInstallationFailureevents (visible in the C# output channel)PackageInstallationFailedwith failure details (packageId, isOptional flag, error details)trueto allow activation to proceedisOptionalfield to ComponentInfo interfaceroslynCopilotis marked as optional (xamlTools and razorDevKit are required as they ship in-box)"Optional component '<name>' could not be found at '<path>'"Telemetry
Package installation failures now send telemetry events with the following properties:
PackageInstallationFailed(single event name for both optional and required packages)installStage- where the failure occurredpackageId- the package identifierisOptional- whether the package was optional (distinguishes optional vs required)error.message- the error messageerror.packageUrl- the package URLThis telemetry now applies to main extension, OmniSharp, and Razor package downloads.
Usage
To mark a runtime dependency as optional in
package.json:{ "id": "OptionalComponent", "description": "Optional Component", "url": "https://example.com/component.zip", "installPath": ".optional", "platforms": ["win32", "darwin", "linux"], "architectures": ["x86_64"], "isOptional": true }Behavior
"isOptional": false): Failure stops extension activation"isOptional": true): Failure is logged with full details but activation continuesgetComponentPathslogs a warning and returns empty array instead of throwingAll failure messages are logged to the C# output channel via the existing
InstallationFailureevent handling infrastructure. Optional component warnings are logged to the appropriate output channel.User Experience
When an optional package fails to download, users see clear error messages in the C# Output Window while the extension continues to activate:
Testing
Fixes #8702
Original prompt
Fixes #8702
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.