E522 Add 'install-powershell.ps1' to install powershell core on windows by daxian-dbw · Pull Request #5383 · PowerShell/PowerShell · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@daxian-dbw
Copy link
Member

Fix #5348 #5367

Add install-powershell.ps1 to install powershell core packages on windows.
Update Start-PSBootStrap to check and install latest PSCore package.

@daxian-dbw
Copy link
Member Author

The Travis CI was successful too, but it's not refreshed here. Please click "Details" to see the builds.

10BC0

$ErrorActionPreference = "Stop"

if (-not $Destination) {
$Destination = "~/pscore"
Copy link
Member

Choose a reason for hiding this comment

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

Should we default to ~/.pscore following .dotnet convention?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't have a preference here. But on windows dotnet-install.ps1 actually installs dotnet in $env:LOCALAPPDATA\Microsoft\dotnet\, only the some helping files are placed in ~/.dotnet.

Copy link
Member

Choose a reason for hiding this comment

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

Perhaps we should use $env:LOCALAPPDATA\Microsoft\powershell

Copy link
Member Author

Choose a reason for hiding this comment

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

OK, will change to that path.

$Destination = Resolve-Path -Path $Destination | ForEach-Object -MemberName Path
Write-Verbose "Destination: $Destination" -Verbose

$architecture = Get-CimInstance win32_operatingsystem | ForEach-Object {
Copy link
Member

Choose a reason for hiding this comment

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

This seems overkill to check architecture, I would simply use:

switch ($env:PROCESSOR_ARCHITECTURE) {
   ...
}

Copy link
Member Author

Choose a reason for hiding this comment

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

$env:PROCESSOR_ARCHITECTURE shows x86 from a x86 windows powershell on a x64 machine. That's why I turned to win32_operatingsystem.

Copy link
Member

Choose a reason for hiding this comment

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

It seems like someone deliberately running x86 powershell would expect to install x86 pscore. Not a blocking issue, but seems unnecessary.

Copy link
Member Author

Choose a reason for hiding this comment

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

I will change back to $env:PROCESSOR_ARCHITECTURE. It would be rare for someone to run a x86 powershell on a x64 machine anyways. We can fix it If it turns out to be an issue.

Expand-Archive -Path $packagePath -DestinationPath $Destination
}

if ($AddToPath -and (-not $env:Path.Contains($Destination))) {
Copy link
Member

Choose a reason for hiding this comment

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

Is there a case where the user wouldn't addtopath? Seems like this would be the primary use case? Perhaps have -DoNotAddToPath instead?

Copy link
Member Author
@daxian-dbw daxian-dbw Nov 9, 2017

Choose a reason for hiding this comment

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

I think when installing daily build package, a user possibly doesn't want it to be added to Path by default.

Copy link
Member

Choose a reason for hiding this comment

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

I'm thinking the opposite where for daily self-hosting, I would want it in the path, although it would only need to be added once, so this isn't a big deal. I'm fine leaving it the way it is.

10000

Copy link
Member Author

Choose a reason for hiding this comment

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

OK. I will leave it unchanged.

if ($AddToPath -and (-not $env:Path.Contains($Destination))) {
## Add to the User scope 'Path' environment variable
$userPath = [System.Environment]::GetEnvironmentVariable("Path", "User")
$userPath += [System.IO.Path]::PathSeparator + $Destination
Copy link
Member

Choose a reason for hiding this comment

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

Should this be in front?

Copy link
Member Author

Choose a reason for hiding this comment

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

OK, will change to add in front.

@daxian-dbw
Copy link
Member Author

macOS CI was canceled several times. This PR only affects AppVeyor CI runs, and given that I will merge this PR.
After merging this PR, I will enhance the script to work on Linux/macOS as well.

@daxian-dbw daxian-dbw merged commit affcc40 into PowerShell:master Nov 10, 2017
@daxian-dbw daxian-dbw deleted the installpowershell branch November 10, 2017 16:28
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.

3 participants

0