|
@@ -1,155 +1,253 @@
|
|
|
-# Visual Studio 2022 Filter Solutions Extension
|
|
|
|
|
|
|
+# Visual Studio 2022 Filtered Solutions Extension v1.0
|
|
|
|
|
+
|
|
|
|
|
+A Visual Studio 2022 extension that automatically presents a project filter dialog when opening solutions with multiple projects, allowing you to create filtered solutions with only the projects you need.
|
|
|
|
|
+
|
|
|
|
|
+## Features
|
|
|
|
|
+
|
|
|
|
|
+- **Automatic Dialog**: Shows project filter dialog when opening solutions with multiple projects
|
|
|
|
|
+- **Project Tree View**: Interactive tree view with checkboxes for project selection
|
|
|
|
|
+- **Smart Dependencies**: Automatically selects/deselects dependent projects when you check/uncheck projects
|
|
|
|
|
+- **Pattern Filtering**: Filter projects using wildcard patterns (e.g., `*.Test`, `Core*`, `*Data*`)
|
|
|
|
|
+- **Bulk Operations**: "Select All" and "Clear All" buttons for quick selection
|
|
|
|
|
+- **Filtered Solutions**: Creates new solution files with only selected projects, leaving originals untouched
|
|
|
|
|
+- **Manual Access**: Menu command for manual filtering of already opened solutions
|
|
|
|
|
|
|
|
## Project Structure
|
|
## Project Structure
|
|
|
```
|
|
```
|
|
|
FilteredSolutionsExtension/
|
|
FilteredSolutionsExtension/
|
|
|
├── FilteredSolutionsExtension.csproj
|
|
├── FilteredSolutionsExtension.csproj
|
|
|
-├── extension.vsixmanifest
|
|
|
|
|
-├── FilterSolutionsPackage.vsct
|
|
|
|
|
-├── FilterSolutionsPackage.cs
|
|
|
|
|
|
|
+├── source.extension.vsixmanifest
|
|
|
|
|
+├── Menus.vsct
|
|
|
|
|
+├── FilteredSolutionsExtensionPackage.cs
|
|
|
|
|
+├── SolutionEventsHandler.cs
|
|
|
├── SolutionOpeningInterceptor.cs
|
|
├── SolutionOpeningInterceptor.cs
|
|
|
-├── ProjectInfo.cs
|
|
|
|
|
-├── SolutionParser.cs
|
|
|
|
|
-├── FilteredSolutionGenerator.cs
|
|
|
|
|
|
|
+├── ManualFilterCommand.cs
|
|
|
├── ProjectFilterDialog.xaml
|
|
├── ProjectFilterDialog.xaml
|
|
|
├── ProjectFilterDialog.xaml.cs
|
|
├── ProjectFilterDialog.xaml.cs
|
|
|
├── ProjectTreeItem.cs
|
|
├── ProjectTreeItem.cs
|
|
|
-└── Properties/
|
|
|
|
|
- └── AssemblyInfo.cs
|
|
|
|
|
|
|
+├── ProjectNode.cs
|
|
|
|
|
+├── ProjectInfo.cs
|
|
|
|
|
+├── SolutionParser.cs
|
|
|
|
|
+├── FilteredSolutionGenerator.cs
|
|
|
|
|
+├── FileUtils.cs
|
|
|
|
|
+├── ErrorHandler.cs
|
|
|
|
|
+├── DebugHelper.cs
|
|
|
|
|
+├── ExtensionSettings.cs
|
|
|
|
|
+├── Properties/
|
|
|
|
|
+│ └── AssemblyInfo.cs
|
|
|
|
|
+└── Resources/
|
|
|
|
|
+ └── FilterSolutionsCommand.png
|
|
|
```
|
|
```
|
|
|
|
|
|
|
|
-## Additional Files Needed
|
|
|
|
|
-
|
|
|
|
|
-### Properties/AssemblyInfo.cs
|
|
|
|
|
-```csharp
|
|
|
|
|
-using System.Reflection;
|
|
|
|
|
-using System.Runtime.InteropServices;
|
|
|
|
|
-
|
|
|
|
|
-[assembly: AssemblyTitle("FilteredSolutionsExtension")]
|
|
|
|
|
-[assembly: AssemblyDescription("Visual Studio extension to filter projects when opening solutions")]
|
|
|
|
|
-[assembly: AssemblyConfiguration("")]
|
|
|
|
|
-[assembly: AssemblyCompany("YourCompany")]
|
|
|
|
|
-[assembly: AssemblyProduct("Filter Solutions Extension")]
|
|
|
|
|
-[assembly: AssemblyCopyright("Copyright © 2025")]
|
|
|
|
|
-[assembly: AssemblyTrademark("")]
|
|
|
|
|
-[assembly: AssemblyCulture("")]
|
|
|
|
|
-[assembly: ComVisible(false)]
|
|
|
|
|
-[assembly: AssemblyVersion("1.0.0.0")]
|
|
|
|
|
-[assembly: AssemblyFileVersion("1.0.0.0")]
|
|
|
|
|
-```
|
|
|
|
|
|
|
+## Technology Stack
|
|
|
|
|
|
|
|
-### Resources/FilterSolutionsCommand.png
|
|
|
|
|
-Create a 16x16 pixel icon for the command button (simple filter icon).
|
|
|
|
|
|
|
+- **Target Framework**: .NET Framework 4.7.2
|
|
|
|
|
+- **Visual Studio SDK**: 17.0+
|
|
|
|
|
+- **UI Framework**: WPF (XAML)
|
|
|
|
|
+- **Package Format**: VSIX
|
|
|
|
|
+- **Threading**: Async/await patterns with Visual Studio JoinableTaskFactory
|
|
|
|
|
+- **JSON Serialization**: System.Text.Json 9.0.5
|
|
|
|
|
|
|
|
-## Building the Extension
|
|
|
|
|
|
|
+## Key Features Implementation
|
|
|
|
|
|
|
|
-1. **Prerequisites:**
|
|
|
|
|
- - Visual Studio 2022 with Visual Studio extension development workload
|
|
|
|
|
- - .NET 9.0 SDK
|
|
|
|
|
|
|
+### 1. Automatic Solution Filtering
|
|
|
|
|
+- **SolutionEventsHandler**: Monitors solution opening events
|
|
|
|
|
+- **SolutionOpeningInterceptor**: Alternative approach using running document table events
|
|
|
|
|
+- **Smart Detection**: Only shows dialog for solutions with multiple projects
|
|
|
|
|
+- **Filtered Solution Detection**: Skips dialog for already filtered solutions
|
|
|
|
|
+
|
|
|
|
|
+### 2. Interactive Project Selection
|
|
|
|
|
+- **ProjectFilterDialog**: WPF dialog with modern UI
|
|
|
|
|
+- **TreeView Control**: Displays projects with checkboxes
|
|
|
|
|
+- **Real-time Updates**: Live selection count and status updates
|
|
|
|
|
+- **Project Icons**: Visual project type indicators
|
|
|
|
|
+
|
|
|
|
|
+### 3. Dependency Management
|
|
|
|
|
+- **Automatic Selection**: Checking a project automatically selects its dependencies
|
|
|
|
|
+- **Cascading Deselection**: Unchecking a project deselects dependent projects
|
|
|
|
|
+- **Project Reference Parsing**: Reads MSBuild project files for accurate dependencies
|
|
|
|
|
+- **Solution-level Dependencies**: Supports both project references and solution dependencies
|
|
|
|
|
+
|
|
|
|
|
+### 4. Advanced Filtering
|
|
|
|
|
+- **Wildcard Support**: Use `*` for pattern matching
|
|
|
|
|
+- **Case-insensitive**: Filtering works regardless of case
|
|
|
|
|
+- **Real-time Filter**: Instant visual filtering as you type
|
|
|
|
|
+- **Filter Examples**:
|
|
|
|
|
+ - `Test*` - Projects starting with "Test"
|
|
|
|
|
+ - `*Core*` - Projects containing "Core"
|
|
|
|
|
+ - `*.Data` - Projects ending with ".Data"
|
|
|
|
|
+
|
|
|
|
|
+### 5. Solution Generation
|
|
|
|
|
+- **FilteredSolutionGenerator**: Creates new .sln files
|
|
|
|
|
+- **Regex-based Parsing**: Robust solution file parsing
|
|
|
|
|
+- **Global Section Filtering**: Properly filters project configurations and dependencies
|
|
|
|
|
+- **Temp Directory**: Creates filtered solutions in system temp folder
|
|
|
|
|
+- **Original Preservation**: Never modifies original solution files
|
|
|
|
|
|
|
|
-2. **Create the Project:**
|
|
|
|
|
- ```bash
|
|
|
|
|
- # Create new VSIX project
|
|
|
|
|
- dotnet new vsix -n FilteredSolutionsExtension
|
|
|
|
|
- cd FilteredSolutionsExtension
|
|
|
|
|
- ```
|
|
|
|
|
|
|
+## Usage Workflow
|
|
|
|
|
|
|
|
-3. **Replace/Add Files:**
|
|
|
|
|
- - Replace the generated files with the code provided above
|
|
|
|
|
- - Ensure all files are in the correct namespace: `FilteredSolutionsExtension`
|
|
|
|
|
|
|
+### Automatic Filtering
|
|
|
|
|
+1. **Open Solution**: Use File → Open → Project/Solution
|
|
|
|
|
+2. **Dialog Appears**: Filter dialog shows automatically for multi-project solutions
|
|
|
|
|
+3. **Select Projects**: Use checkboxes, search filter, or bulk selection
|
|
|
|
|
+4. **Dependencies**: Required dependencies are automatically included
|
|
|
|
|
+5. **Create**: Click "Create Filtered Solution" to generate and open filtered solution
|
|
|
|
|
+6. **Alternative**: Click "Open All Projects" to continue with full solution
|
|
|
|
|
+
|
|
|
|
|
+### Manual Filtering
|
|
|
|
|
+1. **Open Solution**: Open any solution normally
|
|
|
|
|
+2. **Access Menu**: Go to File → "Filter Solution Projects..."
|
|
|
|
|
+3. **Filter Projects**: Use the same dialog interface
|
|
|
|
|
+4. **Generate**: Create filtered solution from currently opened solution
|
|
|
|
|
+
|
|
|
|
|
+### Dialog Controls
|
|
|
|
|
+- **Filter Pattern**: Text input with wildcard support
|
|
|
|
|
+- **Apply Filter/Clear**: Apply or reset filtering
|
|
|
|
|
+- **Select All/Clear All**: Bulk selection operations
|
|
|
|
|
+- **Project Tree**: Checkboxes with dependency indicators
|
|
|
|
|
+- **Selection Count**: Real-time count of selected projects
|
|
|
|
|
+- **Status Bar**: Progress and status information
|
|
|
|
|
|
|
|
-4. **Build:**
|
|
|
|
|
- ```bash
|
|
|
|
|
- dotnet build --configuration Release
|
|
|
|
|
- ```
|
|
|
|
|
|
|
+## Building the Extension
|
|
|
|
|
|
|
|
-## Key Features Implementation
|
|
|
|
|
|
|
+### Prerequisites
|
|
|
|
|
+- Visual Studio 2022 with Visual Studio extension development workload
|
|
|
|
|
+- .NET Framework 4.7.2 SDK
|
|
|
|
|
+- .NET 9.0 SDK
|
|
|
|
|
|
|
|
-### 1. Solution Opening Interception
|
|
|
|
|
-- Uses `SolutionOpeningInterceptor` to monitor DTE solution events
|
|
|
|
|
-- Intercepts after solution is opened but before projects are fully loaded
|
|
|
|
|
-- Prevents duplicate dialogs with solution tracking
|
|
|
|
|
|
|
+### Build Steps
|
|
|
|
|
+1. **Clone/Download**: Get the source code
|
|
|
|
|
+2. **Open in VS**: Open FilteredSolutionsExtension.sln
|
|
|
|
|
+3. **Restore Packages**: NuGet packages will restore automatically
|
|
|
|
|
+4. **Build**: Build → Build Solution (Ctrl+Shift+B)
|
|
|
|
|
+5. **VSIX Output**: Find the .vsix file in bin/Debug or bin/Release
|
|
|
|
|
|
|
|
-### 2. Project Tree with Dependencies
|
|
|
|
|
-- Displays all projects in a tree view with checkboxes
|
|
|
|
|
-- Automatically handles project dependencies:
|
|
|
|
|
- - Checking a project auto-checks its dependencies
|
|
|
|
|
- - Unchecking a project auto-unchecks dependent projects
|
|
|
|
|
|
|
+### Debug/Test
|
|
|
|
|
+1. **Set Startup**: Set the VSIX project as startup project
|
|
|
|
|
+2. **Press F5**: Launches experimental instance of Visual Studio
|
|
|
|
|
+3. **Test**: Open a multi-project solution to test the extension
|
|
|
|
|
|
|
|
-### 3. Filtering Capabilities
|
|
|
|
|
-- Text-based pattern filtering with wildcard support (* and ?)
|
|
|
|
|
-- "Select All" and "Clear All" functionality
|
|
|
|
|
-- Real-time filtering of project list
|
|
|
|
|
|
|
+## Installation
|
|
|
|
|
|
|
|
-### 4. Solution Generation
|
|
|
|
|
-- Creates filtered `.sln` file in temp directory
|
|
|
|
|
-- Preserves original solution file
|
|
|
|
|
-- Only includes selected projects and their dependencies
|
|
|
|
|
-- Maintains proper solution file format
|
|
|
|
|
|
|
+### From Build
|
|
|
|
|
+1. **Build VSIX**: Follow build steps above
|
|
|
|
|
+2. **Install**: Double-click the generated .vsix file
|
|
|
|
|
+3. **Restart**: Restart Visual Studio if required
|
|
|
|
|
+
|
|
|
|
|
+### From VSIX File
|
|
|
|
|
+1. **Double-click**: Double-click the .vsix file
|
|
|
|
|
+2. **VS Installer**: Visual Studio Installer will open
|
|
|
|
|
+3. **Install**: Follow installation prompts
|
|
|
|
|
+4. **Verify**: Check Extensions → Manage Extensions
|
|
|
|
|
+
|
|
|
|
|
+## Configuration
|
|
|
|
|
+
|
|
|
|
|
+### Settings (Future Enhancement)
|
|
|
|
|
+The extension includes `ExtensionSettings.cs` for future configuration options:
|
|
|
|
|
+- Auto-show filter dialog preference
|
|
|
|
|
+- Remember last selection per solution
|
|
|
|
|
+- Default filter patterns
|
|
|
|
|
+- Auto-select dependencies preference
|
|
|
|
|
+- Show project paths in tree
|
|
|
|
|
+
|
|
|
|
|
+### Current Behavior
|
|
|
|
|
+- Always shows dialog for multi-project solutions
|
|
|
|
|
+- Always includes dependencies automatically
|
|
|
|
|
+- Creates filtered solutions in temp directory
|
|
|
|
|
+- Preserves original solution files
|
|
|
|
|
+
|
|
|
|
|
+## Architecture
|
|
|
|
|
+
|
|
|
|
|
+### Threading Model
|
|
|
|
|
+- **Async/Await**: Modern async patterns throughout
|
|
|
|
|
+- **UI Thread Safety**: Proper thread marshaling for UI operations
|
|
|
|
|
+- **JoinableTaskFactory**: Visual Studio recommended threading
|
|
|
|
|
+- **Background Processing**: Solution parsing on background threads
|
|
|
|
|
+
|
|
|
|
|
+### Error Handling
|
|
|
|
|
+- **ErrorHandler**: Centralized error logging and user notification
|
|
|
|
|
+- **DebugHelper**: Development debugging utilities
|
|
|
|
|
+- **Graceful Degradation**: Continues operation on non-critical errors
|
|
|
|
|
+- **User Feedback**: Clear error messages and status updates
|
|
|
|
|
+
|
|
|
|
|
+### File Operations
|
|
|
|
|
+- **FileUtils**: Async file operations compatible with .NET 4.7.2
|
|
|
|
|
+- **Solution Parsing**: Robust regex-based solution file parsing
|
|
|
|
|
+- **Project Analysis**: MSBuild project file dependency analysis
|
|
|
|
|
+- **Temp Management**: Automatic cleanup of temporary files
|
|
|
|
|
+
|
|
|
|
|
+## Known Limitations
|
|
|
|
|
+
|
|
|
|
|
+1. **Project Types**: Only works with standard MSBuild-based projects
|
|
|
|
|
+2. **Solution Folders**: Solution folders are filtered out during parsing
|
|
|
|
|
+3. **Complex Dependencies**: Some complex project configurations may need manual adjustment
|
|
|
|
|
+4. **Performance**: Large solutions (100+ projects) may take time to parse
|
|
|
|
|
+5. **Temporary Solutions**: Filtered solutions are created in temp directory
|
|
|
|
|
|
|
|
-## Usage Workflow
|
|
|
|
|
|
|
+## Troubleshooting
|
|
|
|
|
|
|
|
-1. **Open Solution:** When opening a solution with multiple projects
|
|
|
|
|
-2. **Dialog Appears:** Project filter dialog shows automatically
|
|
|
|
|
-3. **Select Projects:** Use checkboxes, filter pattern, or bulk selection
|
|
|
|
|
-4. **Dependencies:** Dependencies are automatically selected/deselected
|
|
|
|
|
-5. **Generate:** Click "OK" to create filtered solution
|
|
|
|
|
-6. **Open Filtered:** Original solution closes, filtered solution opens
|
|
|
|
|
|
|
+### Common Issues
|
|
|
|
|
|
|
|
-## Advanced Configuration
|
|
|
|
|
|
|
+**Dialog doesn't appear**
|
|
|
|
|
+- Ensure solution has multiple projects
|
|
|
|
|
+- Check if solution is already filtered (temp file)
|
|
|
|
|
+- Verify extension is installed and enabled
|
|
|
|
|
|
|
|
-### Customizing Auto-Load Behavior
|
|
|
|
|
-In `FilterSolutionsPackage.cs`, modify the `ProvideAutoLoad` attributes:
|
|
|
|
|
-```csharp
|
|
|
|
|
-[ProvideAutoLoad(UIContextGuids80.NoSolution, PackageAutoLoadFlags.BackgroundLoad)]
|
|
|
|
|
-[ProvideAutoLoad(UIContextGuids80.SolutionExists, PackageAutoLoadFlags.BackgroundLoad)]
|
|
|
|
|
-```
|
|
|
|
|
|
|
+**Dependencies not working**
|
|
|
|
|
+- Check project references in original solution
|
|
|
|
|
+- Verify project GUIDs are consistent
|
|
|
|
|
+- Look for circular dependencies
|
|
|
|
|
|
|
|
-### Adding Command Menu
|
|
|
|
|
-The extension includes a `.vsct` file that adds a "Filter Solutions..." command to the File menu for manual triggering.
|
|
|
|
|
|
|
+**Filtered solution won't open**
|
|
|
|
|
+- Check temp directory permissions
|
|
|
|
|
+- Ensure original project files exist
|
|
|
|
|
+- Verify project file paths are correct
|
|
|
|
|
|
|
|
-### Debugging
|
|
|
|
|
-1. Set the startup project to the VSIX project
|
|
|
|
|
-2. Press F5 to launch experimental instance of Visual Studio
|
|
|
|
|
-3. Open a solution to test the extension
|
|
|
|
|
|
|
+**Extension won't load**
|
|
|
|
|
+- Confirm Visual Studio 2022 compatibility
|
|
|
|
|
+- Check Windows Event Log for errors
|
|
|
|
|
+- Verify all dependencies are installed
|
|
|
|
|
|
|
|
-## Installation
|
|
|
|
|
|
|
+### Debug Information
|
|
|
|
|
+- Extension logs to Visual Studio Output window
|
|
|
|
|
+- Check debug output for detailed error information
|
|
|
|
|
+- Use DebugHelper.GetLogPath() for file-based logging
|
|
|
|
|
+
|
|
|
|
|
+## Future Enhancements
|
|
|
|
|
|
|
|
-1. **Build the VSIX:**
|
|
|
|
|
- ```bash
|
|
|
|
|
- dotnet build --configuration Release
|
|
|
|
|
- ```
|
|
|
|
|
|
|
+- **Settings Dialog**: UI for configuring extension behavior
|
|
|
|
|
+- **Solution Folder Support**: Include solution folders in filtering
|
|
|
|
|
+- **Template Support**: Save and load project selection templates
|
|
|
|
|
+- **Performance Optimization**: Faster parsing for large solutions
|
|
|
|
|
+- **Integration**: Better integration with Solution Explorer
|
|
|
|
|
+- **Batch Processing**: Process multiple solutions at once
|
|
|
|
|
+- **Export/Import**: Share filter configurations between machines
|
|
|
|
|
|
|
|
-2. **Install Extension:**
|
|
|
|
|
- - Double-click the generated `.vsix` file in `bin/Release/`
|
|
|
|
|
- - Or use Visual Studio Extensions Manager
|
|
|
|
|
|
|
+## Contributing
|
|
|
|
|
|
|
|
-3. **Verify Installation:**
|
|
|
|
|
- - Check Extensions > Manage Extensions
|
|
|
|
|
- - Look for "Filter Solutions Extension"
|
|
|
|
|
|
|
+1. **Fork**: Fork the repository
|
|
|
|
|
+2. **Branch**: Create feature branch
|
|
|
|
|
+3. **Develop**: Make changes following existing patterns
|
|
|
|
|
+4. **Test**: Test with various solution types
|
|
|
|
|
+5. **Pull Request**: Submit PR with description
|
|
|
|
|
|
|
|
-## Troubleshooting
|
|
|
|
|
|
|
+## License
|
|
|
|
|
|
|
|
-### Common Issues:
|
|
|
|
|
-1. **Dialog doesn't appear:** Check that solution has multiple projects
|
|
|
|
|
-2. **Dependencies not working:** Verify project references in original solution
|
|
|
|
|
-3. **Filtered solution won't open:** Check temp directory permissions
|
|
|
|
|
-4. **Extension won't load:** Verify Visual Studio 2022 compatibility
|
|
|
|
|
|
|
+This project is provided as-is for educational and development purposes.
|
|
|
|
|
|
|
|
-### Debug Output:
|
|
|
|
|
-The extension writes debug information to Visual Studio Output window. Check for error messages in the debug output.
|
|
|
|
|
|
|
+## Version History
|
|
|
|
|
|
|
|
-## Limitations
|
|
|
|
|
|
|
+### 1.0.0 - Initial Release
|
|
|
|
|
+- Core project filtering functionality
|
|
|
|
|
+- Automatic dialog on solution open
|
|
|
|
|
+- Manual filtering command
|
|
|
|
|
+- Dependency management
|
|
|
|
|
+- Pattern-based filtering
|
|
|
|
|
+- Modern async/await architecture
|
|
|
|
|
+- Comprehensive error handling
|
|
|
|
|
|
|
|
-1. Only works with standard MSBuild-based projects
|
|
|
|
|
-2. Solution folders are filtered out during parsing
|
|
|
|
|
-3. Temporary solutions are created in system temp directory
|
|
|
|
|
-4. Complex project configurations may need manual adjustment
|
|
|
|
|
|
|
+---
|
|
|
|
|
|
|
|
-## Future Enhancements
|
|
|
|
|
|
|
+**Happy Coding!** 🚀
|
|
|
|
|
|
|
|
-- Remember user preferences for project selection
|
|
|
|
|
-- Support for solution folders
|
|
|
|
|
-- Integration with Visual Studio's solution explorer
|
|
|
|
|
-- Batch processing of multiple solutions
|
|
|
|
|
-- Export/import of filter configurations
|
|
|
|
|
|
|
+This extension streamlines your Visual Studio workflow by letting you work with only the projects you need, making large solutions more manageable and improving build times.
|