GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Enable install-powershell.ps1 to work from powershell-daily folder by SteveL-MSFT · Pull Request #5429 · PowerShell/PowerShell Conversation
Member
To make it easier to selfhost daily:
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsenable running from installed daily by using temp folder …ng files as they are in use and copy over the new ones
Steve Lee (SteveL-MSFT)
requested review from
Travis Plunk (TravisEz13) and
Aditya Patwardhan (adityapatwardhan)
as code owners
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Still reviewing.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should get the unresolved absolute provider path for
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
|
| } | ||
|
|
||
| Remove-Destination $Destination | ||
| Move-Item -Path "$Destination.new" -Destination $Destination |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
If you can use Move-Item here, I think you can do the same in the daily code path without having to differentiate between $Destination exists or not (line 127).
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The differentiation is needed when $Destination is in use (because install-powershell was run from $Destination) so I can't use the Move-Item optimization.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
When installing a release package here, the Destination could also be $PSHOME, right?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's true. Will fix.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I just tried install-powershell.ps1 -Destination $PSHOME on Windows, and new files are not moved to $PSHOME after the run.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| if (Test-Path -Path "$Destination.old") { | ||
| Remove-Item "$Destination.old" -Recurse -Force | ||
| } | ||
| if ($IsWinEnv -and ($Destination -eq $PSHome)) { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I didn't know that on Linux you can delete $PSHome from a running powershell.
Can you please add some comment in Remove-Destination about the different scenarios of the remove operation?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Sure
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| } | ||
|
|
||
| Remove-Destination $Destination | ||
| Move-Item -Path "$Destination.new" -Destination $Destination |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I just tried install-powershell.ps1 -Destination $PSHOME on Windows, and new files are not moved to $PSHOME after the run.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| Copy-Item -Path $contentPath\* -Destination $Destination -Recurse -Force | ||
| if (Test-Path $Destination) { | ||
| Write-Verbose "Copying files" -Verbose | ||
| Copy-Item -Recurse -Path "$contentPath\*" -Destination $Destination -ErrorAction Ignore |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't specify -ErrorAction Ignore, if it fails to copy a file then the installation fails. And maybe add -Force.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The failure is due to it copying folders, I can change this to filter to just files and letting it fail
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| $contentPath = [System.IO.Path]::Combine($tempDir, $packageName, "content") | ||
| Copy-Item -Path $contentPath\* -Destination $Destination -Recurse -Force | ||
| if (Test-Path $Destination) { | ||
| Write-Verbose "Copying files" -Verbose |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I think this log message should be moved before if (Test-Path $Destination) since both copy-item and move-item would take time. Maybe change the message to Deploying files ...
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Move-Item is just updating a single directory pointer so shouldn't take any time
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
restarted macOS ci |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Still testing, don't merge yet |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Working for me. I think it's ready to go. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
PowerShell#5429) 1. Remove `[validate]` attribute from parameter so this script can be invoked directly from the web. This doesn't have any negative impact as the $Destination parameter will have a default value if null or empty. 2. Move removal of destination folder later as installing the package requires package management module and archive module (on Windows) 3. On Windows, because files have open handles when run from existing powershell-daily install, I rename the existing files and copy over the new ones. User needs to exit and restart `pwsh` to take effect (similar to macOS/Linux where you have to exit and restart anyways)
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.