Compare commits
3 Commits
6d2e099eb4
...
734b49bc7d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
734b49bc7d | ||
|
|
985c4a0a8a | ||
|
|
f55cb444e7 |
@@ -257,12 +257,14 @@ $results = @{
|
|||||||
PowerShell = $false
|
PowerShell = $false
|
||||||
Git = $false
|
Git = $false
|
||||||
VSCode = $false
|
VSCode = $false
|
||||||
|
VSCodeExtensions = $false
|
||||||
|
VSCodePowerShellIntegration = $null # null = not asked, true = configured, false = skipped/failed
|
||||||
Python = $null # null = not attempted, true = success, false = failed
|
Python = $null # null = not attempted, true = success, false = failed
|
||||||
WindowsTerminal = $null
|
WindowsTerminal = $null
|
||||||
}
|
}
|
||||||
|
|
||||||
# Progress tracking
|
# Progress tracking
|
||||||
$totalSteps = 3 # Required installations
|
$totalSteps = 4 # Required installations + extensions
|
||||||
$currentStep = 0
|
$currentStep = 0
|
||||||
|
|
||||||
Write-Host "`nStarting installation..." -ForegroundColor Cyan
|
Write-Host "`nStarting installation..." -ForegroundColor Cyan
|
||||||
@@ -280,6 +282,99 @@ function Write-ProgressIndicator {
|
|||||||
Write-Progress -Activity $Activity -Status $Status -PercentComplete $PercentComplete
|
Write-Progress -Activity $Activity -Status $Status -PercentComplete $PercentComplete
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function Install-VSCodeExtension {
|
||||||
|
param(
|
||||||
|
[string]$ExtensionId,
|
||||||
|
[string]$ExtensionName
|
||||||
|
)
|
||||||
|
|
||||||
|
Write-Host " Installing VSCode extension: $ExtensionName" -ForegroundColor Cyan
|
||||||
|
|
||||||
|
try {
|
||||||
|
# Refresh environment to ensure code command is available
|
||||||
|
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
|
||||||
|
|
||||||
|
$result = & code --install-extension $ExtensionId 2>&1
|
||||||
|
|
||||||
|
if ($LASTEXITCODE -eq 0) {
|
||||||
|
Write-Success "VSCode extension '$ExtensionName' installed successfully"
|
||||||
|
return $true
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Write-Warning "Failed to install VSCode extension '$ExtensionName'"
|
||||||
|
Write-Host " You can install it manually later: Ctrl+Shift+X → Search '$ExtensionName'" -ForegroundColor Gray
|
||||||
|
return $false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
Write-Warning "Could not install VSCode extension '$ExtensionName`: $_"
|
||||||
|
Write-Host " You can install it manually later: Ctrl+Shift+X → Search '$ExtensionName'" -ForegroundColor Gray
|
||||||
|
return $false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function Set-VSCodePowerShellIntegration {
|
||||||
|
# Ask user if they want to set PowerShell 7 as default terminal
|
||||||
|
$setAsDefault = Get-UserConfirmation "Set PowerShell 7 as the default terminal in VSCode? (Recommended for this workshop)"
|
||||||
|
|
||||||
|
if (-not $setAsDefault) {
|
||||||
|
Write-Host " Skipping PowerShell 7 terminal configuration." -ForegroundColor Gray
|
||||||
|
return $false
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host " Configuring PowerShell 7 integration with VSCode..." -ForegroundColor Cyan
|
||||||
|
|
||||||
|
try {
|
||||||
|
# Set PowerShell 7 as the default terminal in VSCode
|
||||||
|
$vscodeSettingsPath = Join-Path $env:APPDATA "Code\User\settings.json"
|
||||||
|
$vscodeSettingsDir = Split-Path $vscodeSettingsPath -Parent
|
||||||
|
|
||||||
|
# Create directory if it doesn't exist
|
||||||
|
if (-not (Test-Path $vscodeSettingsDir)) {
|
||||||
|
New-Item -Path $vscodeSettingsDir -ItemType Directory -Force | Out-Null
|
||||||
|
}
|
||||||
|
|
||||||
|
# Read existing settings or create new
|
||||||
|
if (Test-Path $vscodeSettingsPath) {
|
||||||
|
$settings = Get-Content $vscodeSettingsPath -Raw | ConvertFrom-Json
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$settings = @{}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Set PowerShell 7 as default terminal
|
||||||
|
if (-not $settings.PSObject.Properties.Name -contains "terminal.integrated.defaultProfile.windows") {
|
||||||
|
$settings | Add-Member -NotePropertyName "terminal.integrated.defaultProfile.windows" -NotePropertyValue "PowerShell"
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$settings."terminal.integrated.defaultProfile.windows" = "PowerShell"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Add terminal profiles if not present
|
||||||
|
if (-not $settings.PSObject.Properties.Name -contains "terminal.integrated.profiles.windows") {
|
||||||
|
$profiles = @{
|
||||||
|
"PowerShell" = @{
|
||||||
|
"source" = "PowerShell"
|
||||||
|
"icon" = "terminal-powershell"
|
||||||
|
"path" = "pwsh.exe"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$settings | Add-Member -NotePropertyName "terminal.integrated.profiles.windows" -NotePropertyValue $profiles
|
||||||
|
}
|
||||||
|
|
||||||
|
# Save settings
|
||||||
|
$settings | ConvertTo-Json -Depth 10 | Set-Content $vscodeSettingsPath
|
||||||
|
|
||||||
|
Write-Success "VSCode configured to use PowerShell 7 as default terminal"
|
||||||
|
return $true
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
Write-Warning "Could not configure VSCode PowerShell integration automatically"
|
||||||
|
Write-Host " You can configure it manually in VSCode: Ctrl+Shift+P → Terminal: Select Default Profile → PowerShell" -ForegroundColor Gray
|
||||||
|
return $false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#region Required Installations
|
#region Required Installations
|
||||||
|
|
||||||
# Install PowerShell 7
|
# Install PowerShell 7
|
||||||
@@ -310,12 +405,35 @@ if ($results.Git) {
|
|||||||
|
|
||||||
# Install Visual Studio Code
|
# Install Visual Studio Code
|
||||||
$currentStep++
|
$currentStep++
|
||||||
Write-ProgressIndicator -Activity "Installing Required Tools" -Status "Installing Visual Studio Code (3/3)" -PercentComplete (($currentStep / $totalSteps) * 100)
|
Write-ProgressIndicator -Activity "Installing Required Tools" -Status "Installing Visual Studio Code (3/4)" -PercentComplete (($currentStep / $totalSteps) * 100)
|
||||||
$results.VSCode = Install-Package `
|
$results.VSCode = Install-Package `
|
||||||
-Name "Visual Studio Code" `
|
-Name "Visual Studio Code" `
|
||||||
-WingetId "Microsoft.VisualStudioCode" `
|
-WingetId "Microsoft.VisualStudioCode" `
|
||||||
-CheckCommand "code"
|
-CheckCommand "code"
|
||||||
|
|
||||||
|
# Install VSCode Extensions and configure PowerShell integration
|
||||||
|
if ($results.VSCode) {
|
||||||
|
$currentStep++
|
||||||
|
Write-ProgressIndicator -Activity "Installing Required Tools" -Status "Installing VSCode Extensions (4/4)" -PercentComplete (($currentStep / $totalSteps) * 100)
|
||||||
|
|
||||||
|
Write-Host ""
|
||||||
|
Write-Step "Configuring VSCode"
|
||||||
|
|
||||||
|
# Install PowerShell extension
|
||||||
|
$powershellExtensionResult = Install-VSCodeExtension -ExtensionId "ms-vscode.PowerShell" -ExtensionName "PowerShell"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Configure PowerShell 7 integration (optional but recommended)
|
||||||
|
$powershellIntegrationResult = Set-VSCodePowerShellIntegration
|
||||||
|
$results.VSCodePowerShellIntegration = $powershellIntegrationResult
|
||||||
|
|
||||||
|
$results.VSCodeExtensions = $powershellExtensionResult
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$results.VSCodeExtensions = $false
|
||||||
|
}
|
||||||
|
|
||||||
# Clear progress bar
|
# Clear progress bar
|
||||||
Write-Progress -Activity "Installing Required Tools" -Completed
|
Write-Progress -Activity "Installing Required Tools" -Completed
|
||||||
|
|
||||||
@@ -380,6 +498,20 @@ else {
|
|||||||
|
|
||||||
if ($results.VSCode) {
|
if ($results.VSCode) {
|
||||||
Write-Success "Visual Studio Code"
|
Write-Success "Visual Studio Code"
|
||||||
|
|
||||||
|
if ($results.VSCodeExtensions) {
|
||||||
|
Write-Success " • PowerShell extension"
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Write-Warning " • VSCode PowerShell extension may need manual installation"
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($results.VSCodePowerShellIntegration -eq $true) {
|
||||||
|
Write-Success " • PowerShell 7 terminal integration"
|
||||||
|
}
|
||||||
|
elseif ($results.VSCodePowerShellIntegration -eq $false) {
|
||||||
|
Write-Host " • PowerShell 7 terminal integration: Skipped" -ForegroundColor Gray
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Write-Error "Visual Studio Code - Installation failed or needs restart"
|
Write-Error "Visual Studio Code - Installation failed or needs restart"
|
||||||
|
|||||||
Reference in New Issue
Block a user