Skip to content

adding Bits-Transfer & user switch to install latest user profile insiders edition #1477

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Aug 23, 2018
18 changes: 17 additions & 1 deletion scripts/Install-VSCode.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@
A validated string defining which build edition or "stream" to download - stable or
insiders edition. If the parameter is not used, then stable is downloaded as default.

.PARAMETER User
Copy link
Contributor

Choose a reason for hiding this comment

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

The main function of this flag is to install VSCode-Insiders (user edition) right? Instead of non-Insiders edition. If that's the case, I would vote for the flag being called something like Insiders for now, and then if we want to make it more complex (e.g. choose between User Profile and non-User Profile) later, we could add another flag.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rjmholt I agree with you. In that case would it make sense for now then to move from the switch into the $BuildEdition parameter as a validation value?

Something like: [ValidateSet("stable","insider-system","insider-userprofile")] ??

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah that's a really good idea!

When present, the latest VSCode "User Profile" Insider Edition will be installed.
if BuildEdition is set to "stable" this will revert back to the current standard.

.PARAMETER AdditionalExtensions
An array of strings that are the fully-qualified names of extensions to be
installed in addition to the PowerShell extension. The fully qualified
Expand Down Expand Up @@ -122,6 +126,10 @@ param(
[ValidateSet("stable","insider")]
[string]$BuildEdition = "stable",

[Parameter()]
[switch]
Copy link
Contributor

Choose a reason for hiding this comment

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

The convention in the rest of the file seems to be putting the type constraint on the same line as the parameter

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed and about to check in

$User,

[Parameter()]
[ValidateNotNull()]
[string[]]$AdditionalExtensions = @(),
Expand Down Expand Up @@ -167,13 +175,21 @@ if (!($IsLinux -or $IsOSX)) {
break;
}
}
if (($User -eq $true) -and ($BuildEdition -eq "Insider")) {
Copy link
Contributor

Choose a reason for hiding this comment

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

You should be able to do just if ($User -and ...) here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed and about to check in

$codeCmdPath = "$env:LocalAppData\Programs\Microsoft VS Code Insiders\bin\code-insiders.cmd"
$appName = "Visual Studio Code - Insiders Edition ($($Architecture) - User)"
$fileUri = "https://vscode-update.azurewebsites.net/latest/$($bitVersion)-user/$($BuildEdition)"
}
else {
$fileUri = "https://vscode-update.azurewebsites.net/latest/$($bitVersion)/$($BuildEdition)"
}
try {
$ProgressPreference = 'SilentlyContinue'

if (!(Test-Path $codeCmdPath)) {
Write-Host "`nDownloading latest $appName..." -ForegroundColor Yellow
Remove-Item -Force "$env:TEMP\vscode-$($BuildEdition).exe" -ErrorAction SilentlyContinue
Invoke-WebRequest -Uri "https://vscode-update.azurewebsites.net/latest/$($bitVersion)/$($BuildEdition)" -OutFile "$env:TEMP\vscode-$($BuildEdition).exe"
Start-BitsTransfer $fileUri -Destination "$env:TEMP\vscode-$($BuildEdition).exe"

Write-Host "`nInstalling $appName..." -ForegroundColor Yellow
Start-Process -Wait "$env:TEMP\vscode-$($BuildEdition).exe" -ArgumentList /silent, /mergetasks=!runcode
Expand Down