Add virtual environment validation notification for Python resources #12086
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Adds a non-blocking error notification when a Python resource attempts to start without a virtual environment being created. This helps developers quickly identify and resolve configuration issues with Python applications in Aspire.
Changes
Virtual Environment Detection
Locationproperty toVirtualEnvironmentclass to expose the virtual environment path without requiring recalculationOnBeforeResourceStartedevent handler inPythonAppResourceBuilderExtensionsto check for virtual environment existence before Python resources startIInteractionService.IsAvailableistrue(i.e., when the dashboard is enabled)WithUvEnvironment()since UV creates the virtual environment automaticallyUser Notification
When a missing virtual environment is detected, an error notification is displayed with:
https://aka.ms/aspire/pythonfor documentation on configuring Python apps in AspireThe notification is non-blocking (fire-and-forget) to avoid preventing the resource from starting, allowing developers to see the error and take corrective action.
Example
When running a Python resource without creating the virtual environment:
The dashboard will display an error notification pointing to the missing virtual environment location, helping developers quickly understand what needs to be fixed.
Testing
Added comprehensive test coverage:
Fixes #issue_number
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.