Skip to content

Sign internals of EXE package so that it works correctly when signed - #15132

Merged
Travis Plunk (TravisEz13) merged 23 commits into
PowerShell:masterfrom
TravisEz13:rebuild/v7.2.0-rebuild.4
Apr 9, 2021
Merged

Travis Plunk (TravisEz13) merged 23 commits into
PowerShell:masterfrom
TravisEz13:rebuild/v7.2.0-rebuild.4

Conversation

@TravisEz13

@TravisEz13 Travis Plunk (TravisEz13) commented Mar 31, 2021 •

Copy link
Copy Markdown
Member

PR Summary

Sign internals of EXE package so that it works correctly when signed

  • Refactor exe package creation into separate function
  • Add functions to enable signing of engine of the exe package
  • Move signing of MSI to package creation Job

PR Context

The extracted EXE and MSI of the wrapper must be signed if the EXE is signed or install will fail.

PR Checklist

@rjmholt Rob Holt (rjmholt) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'd like to get someone who understand this better to review it as well if I can. Aditya Patwardhan (@adityapatwardhan), Andrew (@anmenaga) or possibly Andy Jordan (@andschwa).

New-ExePackage -ProductVersion '$(version)' -MsiLocationPath $msiPath -ProductTargetArchitecture ${{ parameters.architecture }}
$exePath = Get-ChildItem '.\PowerShell-*.exe' | Select-Object -First 1 -ExpandProperty fullname
$enginePath = Join-Path -Path '$(System.ArtifactsDirectory)\unsignedEngine' -ChildPath engine.exe
Dismount-ExePackageEngine -ExePath $exePath -EnginePath $enginePath

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm mostly not clear on the Mount/Dismount-ExePackageEngine uses here:

  • Why is it Mount/Dismount? What does it leave on the filesystem?
  • Why do we dismount in one task and then mount later in another?
  • Are we depending on filesystem state between tasks?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It's more like an archive.... so perhaps... Expand/Compress

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

That makes some sense. What is exe package engine? What does each command do? Can we add comments that contain the answers to those questions and ideally the questions above?

@TravisEz13 Travis Plunk (TravisEz13) Apr 6, 2021 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The engine of the exe is the installer engine provided by WiX

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Ok having read a bit about insignia, here are my recommendations:

  • Rename the functions to Disconnect-/Connect-ExePackageEngine
  • Add a comment in the function definitions like Needed to detach the WIX Burn engine from the exe for signing and Needed to reattach the WIX Burn engine to the exe after signing
  • Add a comment in the YAML-embedded script where we detach saying Detach the packaging engine so we can sign the exe
  • Add a similar comment when we re-attach saying Re-attach the packaging engine to the now-signed exe so we can create the MSI

It's not clear from this file why we need to re-attach Burn at the end though. We seem to do the following:

  • sign the exe
  • re-attach Burn to the exe
  • upload it (but the display name says unsigned??)

I don't follow this sequence.

New-ExePackage -ProductVersion '$(version)' -MsiLocationPath $msiPath -ProductTargetArchitecture ${{ parameters.architecture }}
$exePath = Get-ChildItem '.\PowerShell-*.exe' | Select-Object -First 1 -ExpandProperty fullname
$enginePath = Join-Path -Path '$(System.ArtifactsDirectory)\unsignedEngine' -ChildPath engine.exe
Dismount-ExePackageEngine -ExePath $exePath -EnginePath $enginePath

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Ok having read a bit about insignia, here are my recommendations:

  • Rename the functions to Disconnect-/Connect-ExePackageEngine
  • Add a comment in the function definitions like Needed to detach the WIX Burn engine from the exe for signing and Needed to reattach the WIX Burn engine to the exe after signing
  • Add a comment in the YAML-embedded script where we detach saying Detach the packaging engine so we can sign the exe
  • Add a similar comment when we re-attach saying Re-attach the packaging engine to the now-signed exe so we can create the MSI

It's not clear from this file why we need to re-attach Burn at the end though. We seem to do the following:

  • sign the exe
  • re-attach Burn to the exe
  • upload it (but the display name says unsigned??)

I don't follow this sequence.

@TravisEz13

Copy link
Copy Markdown
Member Author

disconnect/connect are not data verbs

@TravisEz13
Travis Plunk (TravisEz13) merged commit 75dc913 into PowerShell:master Apr 9, 2021
@TravisEz13
Travis Plunk (TravisEz13) deleted the rebuild/v7.2.0-rebuild.4 branch April 9, 2021 17:26
@TravisEz13 Travis Plunk (TravisEz13) added the CL-BuildPackaging Indicates that a PR should be marked as a build or packaging change in the Change Log label Apr 9, 2021
@ghost

Copy link
Copy Markdown

🎉v7.2.0-preview.5 has been released which incorporates this pull request.:tada:

Handy links:

Travis Plunk (TravisEz13) added a commit that referenced this pull request Apr 16, 2021
[7.2.0-preview.5] - 2021-04-14

* Breaking Changes

- Make PowerShell Linux deb and RPM packages universal (#15109)
- Enforce AppLocker Deny configuration before Execution Policy Bypass configuration (#15035)
- Disallow mixed dash and slash in command line parameter prefix (#15142) (Thanks @davidBar-On!)

* Experimental Features

- `PSNativeCommandArgumentPassing`: Use `ArgumentList` for native executable invocation (breaking change) (#14692)

* Engine Updates and Fixes

- Add `IArgumentCompleterFactory` for parameterized `ArgumentCompleters` (#12605) (Thanks @powercode!)

* General Cmdlet Updates and Fixes

- Fix SSH remoting connection never finishing with misconfigured endpoint (#15175)
- Respect `TERM` and `NO_COLOR` environment variables for `$PSStyle` rendering (#14969)
- Use `ProgressView.Classic` when Virtual Terminal is not supported (#15048)
- Fix `Get-Counter` issue with `-Computer` parameter (#15166) (Thanks @krishnayalavarthi!)
- Fix redundant iteration while splitting lines (#14851) (Thanks @hez2010!)
- Enhance `Remove-Item -Recurse` to work with OneDrive (#14902) (Thanks @iSazonov!)
- Change minimum depth to 0 for `ConvertTo-Json` (#14830) (Thanks @kvprasoon!)
- Allow `Set-Clipboard` to accept empty string (#14579)
- Turn on and off `DECCKM` to modify keyboard mode for Unix native commands to work correctly (#14943)
- Fall back to `CopyAndDelete()` when `MoveTo()` fails due to an `IOException` (#15077)

* Code Cleanup

<details>

<summary>

<p>We thank the following contributors!</p>
<p>@xtqqczze, @iSazonov, @ZhiZe-ZG</p>

</summary>

<ul>
<li>Update .NET to <code>6.0.0-preview.3</code> (#15221)</li>
<li>Add space before comma to hosting test to fix error reported by <code>SA1001</code> (#15224)</li>
<li>Add <code>SecureStringHelper.FromPlainTextString</code> helper method for efficient secure string creation (#14124) (Thanks @xtqqczze!)</li>
<li>Use static lambda keyword (#15154) (Thanks @iSazonov!)</li>
<li>Remove unnecessary <code>Array</code> -&gt; <code>List</code> -&gt; <code>Array</code> conversion in <code>ProcessBaseCommand.AllProcesses</code> (#15052) (Thanks @xtqqczze!)</li>
<li>Standardize grammar comments in Parser.cs (#15114) (Thanks @ZhiZe-ZG!)</li>
<li>Enable <code>SA1001</code>: Commas should be spaced correctly (#14171) (Thanks @xtqqczze!)</li>
<li>Refactor <code>MultipleServiceCommandBase.AllServices</code> (#15053) (Thanks @xtqqczze!)</li>
</ul>

</details>

* Tools

- Use Unix line endings for shell scripts (#15180) (Thanks @xtqqczze!)

* Tests

- Add the missing tag in Host Utilities tests (#14983)
- Update `copy-props` version in `package.json` (#15124)

* Build and Packaging Improvements

<details>

<summary>

<p>We thank the following contributors!</p>
<p>@JustinGrote</p>

</summary>

<ul>
<li>Fix <code>yarn-lock</code> for <code>copy-props</code> (#15225)</li>
<li>Make package validation regex accept universal Linux packages (#15226)</li>
<li>Bump NJsonSchema from 10.4.0 to 10.4.1 (#15190)</li>
<li>Make MSI and EXE signing always copy to fix daily build (#15191)</li>
<li>Sign internals of EXE package so that it works correctly when signed (#15132)</li>
<li>Bump Microsoft.NET.Test.Sdk from 16.9.1 to 16.9.4 (#15141)</li>
<li>Update daily release tag format to  work with new Microsoft Update work (#15164)</li>
<li>Feature: Add Ubuntu 20.04 Support to install-powershell.sh (#15095) (Thanks @JustinGrote!)</li>
<li>Treat rebuild branches like release branches (#15099)</li>
<li>Update WiX to 3.11.2 (#15097)</li>
<li>Bump NJsonSchema from 10.3.11 to 10.4.0 (#15092)</li>
<li>Allow patching of preview releases (#15074)</li>
<li>Bump Newtonsoft.Json from 12.0.3 to 13.0.1 (#15084, #15085)</li>
<li>Update the <code>minSize</code> build package filter to be explicit (#15055)</li>
<li>Bump NJsonSchema from 10.3.10 to 10.3.11 (#14965)</li>
</ul>

</details>

* Documentation and Help Content

- Merge `7.2.0-preview.4` changes to master (#15056)
- Update `README` and `metadata.json` (#15046)
- Fix broken links for `dotnet` CLI (#14937)

[7.2.0-preview.5]: v7.2.0-preview.4...v7.2.0-preview.5
Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
[7.2.0-preview.5] - 2021-04-14

* Breaking Changes

- Make PowerShell Linux deb and RPM packages universal (PowerShell#15109)
- Enforce AppLocker Deny configuration before Execution Policy Bypass configuration (PowerShell#15035)
- Disallow mixed dash and slash in command line parameter prefix (PowerShell#15142) (Thanks @davidBar-On!)

* Experimental Features

- `PSNativeCommandArgumentPassing`: Use `ArgumentList` for native executable invocation (breaking change) (PowerShell#14692)

* Engine Updates and Fixes

- Add `IArgumentCompleterFactory` for parameterized `ArgumentCompleters` (PowerShell#12605) (Thanks @powercode!)

* General Cmdlet Updates and Fixes

- Fix SSH remoting connection never finishing with misconfigured endpoint (PowerShell#15175)
- Respect `TERM` and `NO_COLOR` environment variables for `$PSStyle` rendering (PowerShell#14969)
- Use `ProgressView.Classic` when Virtual Terminal is not supported (PowerShell#15048)
- Fix `Get-Counter` issue with `-Computer` parameter (PowerShell#15166) (Thanks @krishnayalavarthi!)
- Fix redundant iteration while splitting lines (PowerShell#14851) (Thanks @hez2010!)
- Enhance `Remove-Item -Recurse` to work with OneDrive (PowerShell#14902) (Thanks @iSazonov!)
- Change minimum depth to 0 for `ConvertTo-Json` (PowerShell#14830) (Thanks @kvprasoon!)
- Allow `Set-Clipboard` to accept empty string (PowerShell#14579)
- Turn on and off `DECCKM` to modify keyboard mode for Unix native commands to work correctly (PowerShell#14943)
- Fall back to `CopyAndDelete()` when `MoveTo()` fails due to an `IOException` (PowerShell#15077)

* Code Cleanup

<details>

<summary>

<p>We thank the following contributors!</p>
<p>@xtqqczze, @iSazonov, @ZhiZe-ZG</p>

</summary>

<ul>
<li>Update .NET to <code>6.0.0-preview.3</code> (PowerShell#15221)</li>
<li>Add space before comma to hosting test to fix error reported by <code>SA1001</code> (PowerShell#15224)</li>
<li>Add <code>SecureStringHelper.FromPlainTextString</code> helper method for efficient secure string creation (PowerShell#14124) (Thanks @xtqqczze!)</li>
<li>Use static lambda keyword (PowerShell#15154) (Thanks @iSazonov!)</li>
<li>Remove unnecessary <code>Array</code> -&gt; <code>List</code> -&gt; <code>Array</code> conversion in <code>ProcessBaseCommand.AllProcesses</code> (PowerShell#15052) (Thanks @xtqqczze!)</li>
<li>Standardize grammar comments in Parser.cs (PowerShell#15114) (Thanks @ZhiZe-ZG!)</li>
<li>Enable <code>SA1001</code>: Commas should be spaced correctly (PowerShell#14171) (Thanks @xtqqczze!)</li>
<li>Refactor <code>MultipleServiceCommandBase.AllServices</code> (PowerShell#15053) (Thanks @xtqqczze!)</li>
</ul>

</details>

* Tools

- Use Unix line endings for shell scripts (PowerShell#15180) (Thanks @xtqqczze!)

* Tests

- Add the missing tag in Host Utilities tests (PowerShell#14983)
- Update `copy-props` version in `package.json` (PowerShell#15124)

* Build and Packaging Improvements

<details>

<summary>

<p>We thank the following contributors!</p>
<p>@JustinGrote</p>

</summary>

<ul>
<li>Fix <code>yarn-lock</code> for <code>copy-props</code> (PowerShell#15225)</li>
<li>Make package validation regex accept universal Linux packages (PowerShell#15226)</li>
<li>Bump NJsonSchema from 10.4.0 to 10.4.1 (PowerShell#15190)</li>
<li>Make MSI and EXE signing always copy to fix daily build (PowerShell#15191)</li>
<li>Sign internals of EXE package so that it works correctly when signed (PowerShell#15132)</li>
<li>Bump Microsoft.NET.Test.Sdk from 16.9.1 to 16.9.4 (PowerShell#15141)</li>
<li>Update daily release tag format to  work with new Microsoft Update work (PowerShell#15164)</li>
<li>Feature: Add Ubuntu 20.04 Support to install-powershell.sh (PowerShell#15095) (Thanks @JustinGrote!)</li>
<li>Treat rebuild branches like release branches (PowerShell#15099)</li>
<li>Update WiX to 3.11.2 (PowerShell#15097)</li>
<li>Bump NJsonSchema from 10.3.11 to 10.4.0 (PowerShell#15092)</li>
<li>Allow patching of preview releases (PowerShell#15074)</li>
<li>Bump Newtonsoft.Json from 12.0.3 to 13.0.1 (PowerShell#15084, PowerShell#15085)</li>
<li>Update the <code>minSize</code> build package filter to be explicit (PowerShell#15055)</li>
<li>Bump NJsonSchema from 10.3.10 to 10.3.11 (PowerShell#14965)</li>
</ul>

</details>

* Documentation and Help Content

- Merge `7.2.0-preview.4` changes to master (PowerShell#15056)
- Update `README` and `metadata.json` (PowerShell#15046)
- Fix broken links for `dotnet` CLI (PowerShell#14937)

[7.2.0-preview.5]: PowerShell/PowerShell@v7.2.0-preview.4...v7.2.0-preview.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-BuildPackaging Indicates that a PR should be marked as a build or packaging change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants