Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions build.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -1442,6 +1442,15 @@ function Start-PSBootstrap {

# Install Windows dependencies if `-Package` or `-BuildWindowsNative` is specified
if ($Environment.IsWindows) {
## need RCEdit to modify the binaries embedded resources
if (-not (Test-Path "~/.rcedit/rcedit-x64.exe"))
Copy link
Collaborator

Choose a reason for hiding this comment

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

What about Windows 32-bit?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, will add 32-bit support

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, I don't think any change is needed here. I believe we build x86 running as x64, so we can still use the x64 rcedit to modify the x86 binary.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Clear. Thanks.

Closed.

{
log "Install RCEdit for modifying exe resources"
$rceditUrl = "https://github.com/electron/rcedit/releases/download/v1.0.0/rcedit-x64.exe"
New-Item -Path "~/.rcedit" -Type Directory -Force > $null
Invoke-WebRequest -OutFile "~/.rcedit/rcedit-x64.exe" -Uri $rceditUrl
}

if ($BuildWindowsNative) {
log "Install Windows dependencies for building PSRP plugin"

Expand Down Expand Up @@ -1862,6 +1871,16 @@ function New-MSIPackage
[Switch] $Force
)

## need RCEdit to modify the binaries embedded resources
if (-not (Test-Path "~/.rcedit/rcedit-x64.exe"))
Copy link
Collaborator

Choose a reason for hiding this comment

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

What about Unix?

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'm not as familiar on non-Windows with regards to viewing resources (which Explorer does easily), is this something I can do easily with Ubuntu? If so, I can move this to the build step rather than packaging.

Copy link
Member Author

Choose a reason for hiding this comment

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

Also rcedit only works on Windows

Copy link
Collaborator

Choose a reason for hiding this comment

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

Get-Item <file> | fl * show ProductVersion on WSL.

Copy link
Member Author

Choose a reason for hiding this comment

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

@iSazonov not working for me with WSL:

PS /mnt/c/Windows/System32/WindowsPowerShell/v1.0> get-item ./powershell.exe | fl *


PSPath            : Microsoft.PowerShell.Core\FileSystem::/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe
PSParentPath      : Microsoft.PowerShell.Core\FileSystem::/mnt/c/Windows/System32/WindowsPowerShell/v1.0
PSChildName       : powershell.exe
PSDrive           : /
PSProvider        : Microsoft.PowerShell.Core\FileSystem
PSIsContainer     : False
Mode              : --r--l
VersionInfo       : File:             /mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe
                    InternalName:
                    OriginalFilename:
                    FileVersion:
                    FileDescription:
                    Product:
                    ProductVersion:

Copy link
Member Author

Choose a reason for hiding this comment

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

It looks like PowerShell is simply using the FileVersionInfo class which doesn't return anything on Linux:

PS /mnt/c/Windows/System32/WindowsPowerShell/v1.0> [System.Diagnostics.FileVersionInfo]::GetVersionInfo("/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe")

ProductVersion   FileVersion      FileName
--------------   -----------      --------
                                  /mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe

but on Windows:

PS C:\Windows\System32\WindowsPowerShell\v1.0> [System.Diagnostics.FileVersionInfo]::GetVersionInfo("C:\Windows\system32
\WindowsPowerShell\v1.0\powershell.exe")

ProductVersion   FileVersion      FileName
--------------   -----------      --------
10.0.17019.1000  10.0.17019.10... C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe

Copy link
Member Author

Choose a reason for hiding this comment

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

Linux ELF binaries probably don't have a resource section to stuff this info into.

Copy link
Collaborator

@iSazonov iSazonov Oct 21, 2017

Choose a reason for hiding this comment

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

@SteveL-MSFT Why you test the Windows FullCLR exe file? In my test I used SMA.dll from PowerShell Core.

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 used Windows PowerShell.exe as I knew that had that info populated. I see that SMA.dll from PSCore6 does have that info as does powershell.exe from PSCore6. So dotnet build is adding that, but the executable doesn't have it.

Copy link
Member Author

Choose a reason for hiding this comment

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

This might be because the executable is an actual ELF binary while the dlls are using the same format as Windows making them portable.

{
throw "RCEdit is required to modify pwsh.exe resources, please run 'Start-PSBootStrap' to install"
}

Start-NativeExecution { & "~/.rcedit/rcedit-x64.exe" (Get-PSOutput) --set-icon "$AssetsPath\Powershell_black.ico" `
--set-file-version $ProductVersion --set-product-version $ProductVersion --set-version-string "ProductName" "PowerShell Core 6" `
--set-version-string "LegalCopyright" "(C) Microsoft Corporation. All Rights Reserved." } | Write-Verbose

## AppVeyor base image might update the version for Wix. Hence, we should
## not hard code version numbers.
$wixToolsetBinPath = "${env:ProgramFiles(x86)}\WiX Toolset *\bin"
Expand Down