GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Enable install-powershell.ps1 to work from powershell-daily folder by SteveL-MSFT · Pull Request #5429 · PowerShell/PowerShell

Enable install-powershell.ps1 to work from powershell-daily folder #5429

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.

Sign up for GitHub

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
Dongbo Wang (daxian-dbw) merged 6 commits into PowerShell:master from SteveL-MSFT:install-powershell
Nov 14, 2017

Uh oh!

There was an error while loading. Please reload this page.

Merged

Enable install-powershell.ps1 to work from powershell-daily folder #5429

Changes from 1 commit
Commits
Show all changes
6 commits
Select commit Hold shift + click to select a range
e58ec0e
remove [validate] attribute so script can be called directly from inv…
SteveL-MSFT Nov 12, 2017
402eb03
enable installing daily build using $env:PSCoreDaily
SteveL-MSFT Nov 12, 2017
5c1c8e2
if using from same folder as being installed for daily, rename existi…
SteveL-MSFT Nov 13, 2017
391ac68
remove $env:pscoredaily usage, can use: iex "& { $(irm 'url') } -daily"
SteveL-MSFT Nov 13, 2017
117427b
address PR feedback
SteveL-MSFT Nov 13, 2017
c1dc92f
fix copying of files to correct destination folder
SteveL-MSFT Nov 14, 2017
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view
Prev Previous commit
Next Next commit
address PR feedback
  • Loading branch information

Uh oh!

There was an error while loading. Please reload this page.

@SteveL-MSFT
SteveL-MSFT committed Nov 13, 2017
commit 117427b300640b334002d1c27783efc6ddd41bc6

There are no files selected for viewing

30 changes: 16 additions & 14 deletions 30 tools/install-powershell.ps1
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ if (-not $Destination) {
$Destination = "${Destination}-daily"
}
}
$Destination = $PSCmdlet.SessionState.Path.GetUnresolvedProviderPathFromPSPath($Destination)
Write-Verbose "Destination: $Destination" -Verbose
Comment thread

@daxian-dbw Dongbo Wang (daxian-dbw) Nov 13, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Should get the unresolved absolute provider path for $Destination. Otherwise, the $Destination -eq $PSHome check below may fail when it should succeed.
You can use

$Destination = $PSCmdlet.SessionState.Path.GetUnresolvedProviderPathFromPSPath($Destination)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@SteveL-MSFT Steve Lee (SteveL-MSFT) Nov 13, 2017

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Will update

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

Function Remove-Destination([string] $Destination) {
Expand All @@ -70,6 +71,7 @@ Function Remove-Destination([string] $Destination) {
}
}
} else {
# Unix systems don't keep open file handles so you can just move files/folders even if in use
Move-Item "$Destination" "$Destination.old"
}
}
Expand Down Expand Up @@ -115,15 +117,7 @@ try {
Write-Verbose "Daily package found. Name: $packageName; Version: $($package.Version)" -Verbose

Install-Package -InputObject $package -Destination $tempDir -ExcludeVersion > $null
Remove-Destination $Destination

$contentPath = [System.IO.Path]::Combine($tempDir, $packageName, "content")
if (Test-Path $Destination) {
Write-Verbose "Copying files" -Verbose
Copy-Item -Recurse -Path "$contentPath\*" -Destination $Destination -ErrorAction Ignore
} else {
Move-Item -Path $contentPath -Destination $Destination
}
} else {
$metadata = Invoke-RestMethod https://api.github.com/repos/powershell/powershell/releases/latest
$release = $metadata.tag_name -replace '^v'
Expand All @@ -141,16 +135,24 @@ try {

$packagePath = Join-Path -Path $tempDir -ChildPath $packageName
Invoke-WebRequest -Uri $downloadURL -OutFile $packagePath
$contentPath = Join-Path -Path $tempDir -ChildPath "new"

New-Item -ItemType Directory -Path "$Destination.new" > $null
New-Item -ItemType Directory -Path $contentPath > $null
if ($IsWinEnv) {
Expand-Archive -Path $packagePath -DestinationPath "$Destination.new"
Expand-Archive -Path $packagePath -DestinationPath $contentPath
} else {
tar zxf $packagePath -C "$Destination.new"
tar zxf $packagePath -C $contentPath
}

Remove-Destination $Destination
Move-Item -Path "$Destination.new" -Destination $Destination
}
Remove-Destination $Destination
if (Test-Path $Destination) {
Write-Verbose "Copying files" -Verbose
# only copy files as folders will already exist at $Destination
Get-ChildItem -Recurse -Path "$contentPath\*" -File | ForEach-Object {
Copy-Item $_ -Destination $Destination
}
} else {
Move-Item -Path $contentPath -Destination $Destination
}

## Change the mode of 'pwsh' to 'rwxr-xr-x' to allow execution
Expand Down
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.