TfsCmdlets icon indicating copy to clipboard operation
TfsCmdlets copied to clipboard

Add Install-TfsShell and Uninstall-TfsShell cmdlets with Windows Terminal support

Open Copilot opened this issue 7 months ago • 1 comments

This PR introduces two new cmdlets that enable users to install and uninstall Azure DevOps Shell shortcuts with intelligent Windows Terminal detection and integration.

Overview

The new cmdlets provide a PowerShell-native way to manage shell shortcuts, automatically detecting Windows Terminal and creating appropriate shortcuts while maintaining backward compatibility with traditional PowerShell environments.

Key Features

Install-TfsShell Cmdlet

  • Automatic Windows Terminal Detection: Uses registry lookups and file system checks to detect if Windows Terminal is installed
  • Conditional Shortcut Creation: Creates Windows Terminal shortcuts when available, falls back to PowerShell shortcuts otherwise
  • Windows Terminal Profile Integration: Deploys JSON profile fragments for both Windows PowerShell and PowerShell Core
  • Flexible Target Support: Supports installation to StartMenu, Desktop, and WindowsTerminal locations
  • Force Mode: Allows forcing PowerShell shortcuts even when Windows Terminal is detected

Uninstall-TfsShell Cmdlet

  • Complete Cleanup: Removes shortcuts from all known locations
  • Profile Management: Removes Windows Terminal profile fragments
  • Selective Removal: Supports target-specific cleanup operations

Enhanced WiX Installer

The MSI installer now includes Windows Terminal detection via registry AppSearch, with conditional component installation that creates Windows Terminal shortcuts when detected or falls back to PowerShell shortcuts for legacy compatibility.

Usage Examples

# Install with auto-detection (default: StartMenu + Desktop)
Install-TfsShell

# Install only to Start Menu
Install-TfsShell -Target StartMenu

# Force PowerShell shortcuts even if Windows Terminal detected
Install-TfsShell -Force

# Remove all shortcuts and profiles
Uninstall-TfsShell

# Remove only Windows Terminal profiles
Uninstall-TfsShell -Target WindowsTerminal

Windows Terminal Integration

Two JSON profile fragments are included:

  • AzureDevOpsShell-WinPS.json: Windows PowerShell profile
  • AzureDevOpsShell-PSCore.json: PowerShell Core profile

Both profiles are configured to launch with Import-Module TfsCmdlets; Enter-TfsShell and use appropriate Windows Terminal icons.

Implementation Details

  • C# Architecture: Follows existing TfsCmdlets patterns with proper ControllerBase inheritance
  • Cross-Platform Aware: Handles non-Windows environments gracefully
  • Comprehensive Error Handling: Try-catch blocks with detailed logging for all operations
  • Registry Safety: Handles registry access failures without breaking functionality
  • Path Validation: Validates all file system paths before operations

Backward Compatibility

The implementation maintains full backward compatibility:

  • Existing chocolatey installer scripts remain unchanged
  • WiX installer creates the same shortcuts as before when Windows Terminal is not detected
  • No breaking changes to existing shell functionality

Fixes #101.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot avatar Aug 06 '25 01:08 Copilot