Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Aug 6, 2025

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 AI and others added 3 commits August 6, 2025 01:57
…inal support

Co-authored-by: igoravl <725797+igoravl@users.noreply.github.com>
Co-authored-by: igoravl <725797+igoravl@users.noreply.github.com>
Co-authored-by: igoravl <725797+igoravl@users.noreply.github.com>
Copilot AI changed the title [WIP] Install-TfsShell & Uninstall-TfsShell Add Install-TfsShell and Uninstall-TfsShell cmdlets with Windows Terminal support Aug 6, 2025
Copilot AI requested a review from igoravl August 6, 2025 02:06
Copilot finished work on behalf of igoravl August 6, 2025 02:06
@github-actions
Copy link

github-actions bot commented Aug 6, 2025

Test Results

0 tests   0 ✅  0s ⏱️
0 suites  0 💤
0 files    0 ❌

Results for commit 5aacea1.

♻️ This comment has been updated with latest results.

{
"name": "Azure DevOps Shell (Windows PowerShell)",
"commandline": "powershell.exe -NoExit -Command \"Import-Module TfsCmdlets; Enter-TfsShell\"",
"icon": "ms-appx:///ProfileIcons/PowerShell.png",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the Assets/TfsCmdlets_Icon_128.png file instead as an icon

}
catch
{
// Registry access might fail, continue with file-based detection
Copy link
Owner

@igoravl igoravl Aug 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Why is the file-based detection at the top of the method? Shouldn't it be here?

Besides, separate the detection logic (registry-based, file-based) in their own methods for readability/maintainability sake.

return null;
}

protected override void CacheParameters()
Copy link
Owner

@igoravl igoravl Aug 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot You should not need to implement this. It's generated by the source generator.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is auto-generated from the XML comments in the actual cmdlet. You don't need to generate it

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is auto-generated from the XML comments in the actual cmdlet. You don't need to generate it

{
"name": "Azure DevOps Shell (PowerShell Core)",
"commandline": "pwsh.exe -NoExit -Command \"Import-Module TfsCmdlets; Enter-TfsShell\"",
"icon": "ms-appx:///ProfileIcons/PowerShellCore.png",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the Assets/TfsCmdlets_Icon_128.png file instead as an icon

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just like with the Windows Terminal profiles, I want to support both PSWindows and PSCore here. The PSCore icon should be conditioned to the presence of PowerShell Core (pwsh.exe). Once it is detected, determine then whether to create it as a regular pwsh.exe shortcut, or a shortcut to Windows Terminal.

@igoravl igoravl self-requested a review August 6, 2025 23:30
Copy link
Owner

@igoravl igoravl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review my comments and do the required changes

@igoravl igoravl marked this pull request as ready for review September 23, 2025 04:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Install-TfsShell & Uninstall-TfsShell

2 participants