Ajouter vscode/install.ps1
This commit is contained in:
157
vscode/install.ps1
Normal file
157
vscode/install.ps1
Normal file
@@ -0,0 +1,157 @@
|
|||||||
|
<#PSScriptInfo
|
||||||
|
|
||||||
|
.VERSION 1.0.0
|
||||||
|
|
||||||
|
.GUID
|
||||||
|
|
||||||
|
.AUTHOR
|
||||||
|
|
||||||
|
.COMPANYNAME
|
||||||
|
|
||||||
|
.COPYRIGHT
|
||||||
|
|
||||||
|
.TAGS install vscode installer
|
||||||
|
|
||||||
|
.LICENSEURI
|
||||||
|
|
||||||
|
.PROJECTURI
|
||||||
|
|
||||||
|
.ICONURI
|
||||||
|
|
||||||
|
.EXTERNALMODULEDEPENDENCIES
|
||||||
|
|
||||||
|
.REQUIREDSCRIPTS
|
||||||
|
|
||||||
|
.EXTERNALSCRIPTDEPENDENCIES
|
||||||
|
|
||||||
|
.RELEASENOTES
|
||||||
|
|
||||||
|
#>
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Installs Visual Studio Code
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
|
||||||
|
.PARAMETER Architecture
|
||||||
|
|
||||||
|
.PARAMETER BuildEdition
|
||||||
|
|
||||||
|
.PARAMETER AdditionalExtensions
|
||||||
|
|
||||||
|
.PARAMETER LaunchWhenDone
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
Install-VSCode.ps1 -Architecture 64-bit -BuildEdition stable -LaunchWhenDone -AdditionalExtensions 'eamodio.gitlens', 'vscodevim.vim'
|
||||||
|
|
||||||
|
.NOTES
|
||||||
|
|
||||||
|
#>
|
||||||
|
[CmdletBinding()]
|
||||||
|
Param(
|
||||||
|
[parameter()]
|
||||||
|
[ValidateSet(,"64-bits","32-bits")]
|
||||||
|
[string]$Architecture = "64-bits",
|
||||||
|
|
||||||
|
[parameter()]
|
||||||
|
[ValidateSet("stable","insider")]
|
||||||
|
[string]$BuildEdition = "stable",
|
||||||
|
|
||||||
|
[Parameter()]
|
||||||
|
[ValidateNotNull()]
|
||||||
|
[string[]]$AdditionalExtensions = @('GitHub.copilot','GitHub.copilot-chat','eamodio.gitlens','ms-vscode.powershell', `
|
||||||
|
'ms-python.vscode-pylance','ms-azuretools.vscode-containers''ms-python.python','ms-python.debugpy', `
|
||||||
|
'ms-vscode.vscode-node-azure-pack','ms-windows-ai-studio.windows-ai-studio','TeamsDevApp.vscode-ai-foundry', `
|
||||||
|
'ms-azuretools.vscode-azureappservice','ms-azuretools.vscode-azurecontainerapps','ms-azuretools.vscode-cosmosdb', `
|
||||||
|
'ms-azuretools.azure-dev','ms-azuretools.vscode-azurefunctions','ms-azure-load-testing.microsoft-testing', `
|
||||||
|
'ms-azuretools.vscode-azureresourcegroups','ms-azuretools.vscode-azurestaticwebapps','ms-azuretools.vscode-azurestorage', `
|
||||||
|
'ms-vscode.vscode-node-azure-pack','ms-azuretools.vscode-azurevirtualmachines','naumovs.color-highlight', `
|
||||||
|
'ms-azuretools.vscode-azure-github-copilot','hashicorp.terraform','redhat.ansible','ms-vscode-remote.remote-ssh', `
|
||||||
|
'ms-vscode-remote.remote-ssh-edit','ms-vscode.remote-explorer','vscode-icons-team.vscode-icons'),
|
||||||
|
|
||||||
|
[switch]$LaunchWhenDone
|
||||||
|
)
|
||||||
|
|
||||||
|
If (($PSVersionTable.PSVersion.Major -le 5) -or $IsWindows) {
|
||||||
|
|
||||||
|
Switch ($Architecture) {
|
||||||
|
"64-bits" {
|
||||||
|
|
||||||
|
If ((Get-CimInstance -ClassName Win32_OperatingSystem).OSArchitecture -eq "64 bits") {
|
||||||
|
$codePath = $env:ProgramFiles
|
||||||
|
$bitVersion = "win32-x64-user"
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
$codePath = $env:ProgramFiles
|
||||||
|
$bitVersion = "win32-arm64-user"
|
||||||
|
$Architecture = "32-bits"
|
||||||
|
}
|
||||||
|
Break;
|
||||||
|
}
|
||||||
|
"32-bits" {
|
||||||
|
Write-host "32-bits"
|
||||||
|
If ((Get-CimInstance -ClassName Win32_OperatingSystem).OSArchitecture -eq "32 bits"){
|
||||||
|
#$codePath = $env:ProgramFiles
|
||||||
|
$codePath = $env:USERPROFILE
|
||||||
|
$bitVersion = "win32-arm64-user"
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
$codePath = ${env:ProgramFiles(x86)}
|
||||||
|
$bitVersion = "win32-x64-user"
|
||||||
|
}
|
||||||
|
Break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Switch ($BuildEdition) {
|
||||||
|
"Stable" {
|
||||||
|
$codeCmdPath = "$codePath\AppData\Local\Programs\Microsoft VS Code\bin\code.cmd"
|
||||||
|
$appName = "Visual Studio Code - Stable Edition ($($Architecture))"
|
||||||
|
Break;
|
||||||
|
}
|
||||||
|
"Insider" {
|
||||||
|
$codeCmdPath = "$codePath\AppData\Local\Programs\Microsoft VS Code\bin\code.cmd"
|
||||||
|
$appName = "Visual Studio Code - Insiders Edition ($($Architecture))"
|
||||||
|
Break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Write-Host $($bitVersion)
|
||||||
|
|
||||||
|
Try {
|
||||||
|
$ProgressPreference = 'SilentlyContinue'
|
||||||
|
|
||||||
|
If (!(Test-Path $codeCmdPath)) {
|
||||||
|
Write-Host "`nTéléchargement de la dernière version $appName..." -ForegroundColor Yellow
|
||||||
|
Remove-Item -Force "$env:TEMP\vscode-$($BuildEdition).exe" -ErrorAction SilentlyContinue
|
||||||
|
Invoke-WebRequest -Uri "https://code.visualstudio.com/sha/download?build=$($BuildEdition)&os=$($bitVersion)" -OutFile "$env:TEMP\vscode-$($BuildEdition).exe"
|
||||||
|
|
||||||
|
Write-Host "`nInstallation $appName..." -ForegroundColor Yellow
|
||||||
|
Start-Process -Wait "$env:TEMP\vscode-$($BuildEdition).exe" -ArgumentList /silent, /mergetasks=!runcode
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
Write-Host "`n$appName est déjà installé." -ForegroundColor Yellow
|
||||||
|
}
|
||||||
|
|
||||||
|
$extensions = @("ms-vscode.PowerShell") + $AdditionalExtensions
|
||||||
|
|
||||||
|
Foreach ($extension in $extensions) {
|
||||||
|
Write-Host "`nInstallation de l'extension $extension ..." -ForegroundColor Yellow
|
||||||
|
& $codeCmdPath --install-extension $extension
|
||||||
|
}
|
||||||
|
|
||||||
|
If ($LaunchWhenDone) {
|
||||||
|
Write-Host "`nInstallation terminée, démarrage $appName...`n`n" -ForegroundColor Green
|
||||||
|
& $codeCmdPath
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
Write-Host "`nL'installation est terminé !`n`n" -ForegroundColor Green
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Finally {
|
||||||
|
$ProgressPreference = 'Continue'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
Write-Error "Ce script n'est actuellement pris en charge que par le système d'exploitation Windows."
|
||||||
|
}
|
Reference in New Issue
Block a user