Install-PSVSCode.ps1
# ? TITEL Install-PSVSCode # ? AUTOR Attila Krick (a.krick@outlook.com) # ? VERSION 2019-07-29 function Install-PSVSCode { <# TODO Umbauen auf: Install-PackageProvider -Name Chocolatey -Force -ForceBootstrap Install-Package -Name VisualStudioCode -Verbose -Force #> $uri = "https://vscode-update.azurewebsites.net/latest/win32-x64/stable" $vsCodeInstallExe = Join-Path -Path $env:USERPROFILE -ChildPath Downloads\VSCodeInstaller.exe Remove-Item -Path $vsCodeInstallExe -Force -ErrorAction Ignore $bitsDL = Start-BitsTransfer -Source $uri -Destination $vsCodeInstallExe -Asynchronous $vsCodePath = Join-Path -Path $env:ProgramFiles -ChildPath '\Microsoft VS Code\bin\code.cmd' while (($bitsDL.JobState -eq "Transferring") -or ($bitsDL.JobState -eq "Connecting")) { Write-Progress -Activity "Downloading: Visual Studio Code" ` -Status "Status $([math]::round($bitsDl.BytesTransferred / 1mb))mb / $([math]::round($bitsDl.BytesTotal / 1mb))mb" ` -PercentComplete ([int]($bitsDl.BytesTransferred / $bitsDl.BytesTotal * 100)) } Complete-BitsTransfer -BitsJob $bitsDl "Downloading: Visual Studio Code COMPLETED !" | Write-Information Start-Process -FilePath $vsCodeInstallExe -ArgumentList /silent, /mergetasks=!runcode -Wait "Visual Studio Code installing COMPLETED !" | Write-Information "Visual Studio Code Extensions installing ..." | Write-Information $vsCodeExtensions = "aaron-bond.better-comments", ` "chrmarti.regex", ` "DotJoshJohnson.xml", ` "humao.rest-client", ` "ms-mssql.mssql", ` "ms-vscode.powershell", ` "vscode-icons-team.vscode-icons", ` "streetsidesoftware.code-spell-checker", ` "streetsidesoftware.code-spell-checker-german", ` "tomoki1207.pdf", ` "yzhang.markdown-all-in-one", ` "yzane.markdown-pdf" $vsCodeExtensions | ForEach-Object -Process { $pinfo = New-Object System.Diagnostics.ProcessStartInfo $pinfo.FileName = $vsCodePath $pinfo.RedirectStandardError = $true $pinfo.RedirectStandardOutput = $true $pinfo.UseShellExecute = $false $pinfo.Arguments = "--install-extension $_", "--force" $p = New-Object System.Diagnostics.Process $p.StartInfo = $pinfo $p.Start() | Out-Null $p.WaitForExit() $out = $p.StandardOutput.ReadToEnd() -replace "[\n]", [String]::Empty $err = $p.StandardError.ReadToEnd() -replace "[\n]", [String]::Empty $exitCode = $p.ExitCode " OUT: {0} | ERR: {1} | EXCODE: {2}" -f $out, $err, $exitCode | Write-Information } "... COMPLETED !" | Write-Information $settingsFile = Join-Path -Path $env:APPDATA -ChildPath Code\User\settings.json @" { "files.autoSave": "afterDelay", "editor.minimap.enabled" : false, "editor.tabCompletion" : "on", "editor.mouseWheelZoom" : true, "explorer.confirmDragAndDrop": false, "explorer.confirmDelete" : false, "terminal.integrated.fontFamily": "Consolas", "terminal.integrated.fontSize" : 15, "terminal.integrated.lineHeight": 0, "workbench.colorTheme": "Default Light+", "workbench.iconTheme" : "material-icon-theme", "powershell.integratedConsole.focusConsoleOnExecute": false, "powershell.sideBar.CommandExplorerVisibility" : false, "powershell.helpCompletion" : "LineComment", "cSpell.language": "en,de", "cSpell.enabledLanguageIds": [ "asciidoc", "c", "cpp", "csharp", "css", "go", "handlebars", "html", "jade", "javascript", "javascriptreact", "json", "latex", "less", "markdown", "php", "plaintext", "powershell", "pub", "python", "restructuredtext", "rust", "scss", "text", "typescript", "typescriptreact", "yml" ], "window.zoomLevel": 0, } "@ | Set-Content $settingsFile -Force "settings.json modifing COMPLETED !" | Write-Information Start-Process -FilePath $vsCodePath "Start Visual Studio Code COMPLETED !" | Write-Information } |