Skip to content

Conversation

@bergmeister
Copy link
Contributor

@bergmeister bergmeister commented Nov 18, 2017

Issue #5012 has highlighted that it is not easy to get started with development work on the Windows installer.

This PR documents for the first time how to build an installable package locally and simplifies the process by moving New-MSIPackage to the packaging module where it better belongs to and more defaults/validation are added as well.

Since New-MSIPackage throws a very nice error with a download link to the required WiX toolset, I decided to not duplicate this in the documentation about having to install the WiX toolset.

I guess the best reviewer is @SteveL-MSFT who recently did a lot of installer work.


We currently have the issue [#3400](https://github.com/PowerShell/PowerShell/issues/3400) tracking this task.

## Building an installer
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Contributor Author

@bergmeister bergmeister Nov 18, 2017

Choose a reason for hiding this comment

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

Start-PSPackage is not very developer friendly because it has requirements such as that the checkout must be at the root of the filesystem and that PowerShell has to be compiled in a very specific way. The purpose of this PR is to make it easier to build MSIs locally when changing WiX code.

Copy link
Member

Choose a reason for hiding this comment

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

Start-PSPackage also does some other checks, but that's more intended for creating a release package and I can understand the scenario for a developer testing their wix changes. However, it's actually pretty easy to have PowerShell repo as your root using either New-PSDrive or Subst.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should support one entry point - it is easily to support (in docs too).
Also it will be best to have the same code (csproj?) to build on local and on GitHub.

build.psm1 Outdated
if ($null -eq (Get-Module packaging))
{
# Import Get-PackageSemanticVersion function from packaging module
Import-Module "$PSScriptRoot\tools\packaging\packaging.psd1"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I was sure we were using auto-loading.

Copy link
Contributor Author

@bergmeister bergmeister Nov 18, 2017

Choose a reason for hiding this comment

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

See the example where it only imports build.psm1. We would need to have a module manifest for the build module then. Or maybe New-MSIPackage should be moved into the packaging module instead?

Copy link
Member

Choose a reason for hiding this comment

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

New-MSIPackage should be moved

build.psm1 Outdated

<#
.Synopsis
Creates a Windows installer MSI file and assumes that the binaries are already built using 'Start-PSBuild'.
Copy link
Member

Choose a reason for hiding this comment

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

change the word file to package


We currently have the issue [#3400](https://github.com/PowerShell/PowerShell/issues/3400) tracking this task.

## Building an installer
Copy link
Member

Choose a reason for hiding this comment

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

Start-PSPackage also does some other checks, but that's more intended for creating a release package and I can understand the scenario for a developer testing their wix changes. However, it's actually pretty easy to have PowerShell repo as your root using either New-PSDrive or Subst.


We currently have the issue [#3400](https://github.com/PowerShell/PowerShell/issues/3400) tracking this task.

## Building an installer
Copy link
Member

Choose a reason for hiding this comment

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

Instead of calling it Building an installer, I think it's more correct to say Building an Installable Package (where installer is msi)

@codecov-io
Copy link

codecov-io commented Nov 18, 2017

Codecov Report

Merging #5499 into master will increase coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5499      +/-   ##
==========================================
+ Coverage   60.83%   60.84%   +0.01%     
==========================================
  Files         924      929       +5     
  Lines      274195   273880     -315     
==========================================
- Hits       166793   166642     -151     
+ Misses     107402   107238     -164
Impacted Files Coverage Δ
....Management.Automation/security/SecurityManager.cs 30.51% <0%> (-7.56%) ⬇️
....PowerShell.Security/security/SignatureCommands.cs 24.77% <0%> (-5.97%) ⬇️
...ft.PowerShell.Security/security/CatalogCommands.cs 80.19% <0%> (-5.95%) ⬇️
...Cmdlet/Common/BasicHtmlWebResponseObject.Common.cs 32.75% <0%> (-5.23%) ⬇️
...s/utility/WebCmdlet/Common/ContentHelper.Common.cs 57.33% <0%> (-5.17%) ⬇️
....Management/commands/management/PingPathCommand.cs 77.94% <0%> (-4.42%) ⬇️
.../System.Management.Automation/engine/Attributes.cs 69.23% <0%> (-3.71%) ⬇️
...agement.Automation/engine/interpreter/Utilities.cs 50.8% <0%> (-2.5%) ⬇️
...nagement.Automation/engine/runtime/MutableTuple.cs 38.51% <0%> (-2.1%) ⬇️
...ment.Automation/engine/CompiledCommandParameter.cs 90.8% <0%> (-1.92%) ⬇️
... and 35 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 79ae396...8f956f3. Read the comment docs.

````powershell
Import-Module .\build.psm1
Start-PSBuild
New-MSIPackage -ProductSourcePath '.\src\powershell-win-core\bin\Debug\netcoreapp2.0\win7-x64\publish' -ProductTargetArchitecture x64 -ProductVersion '1.2.3'
Copy link
Member

Choose a reason for hiding this comment

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

New-MSI package should not be exposed.

Copy link
Member

Choose a reason for hiding this comment

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

You could document how to use start-PsPackage for this purpose with the -SkipReleaseChecks parameter.

Copy link
Member

@TravisEz13 TravisEz13 left a comment

Choose a reason for hiding this comment

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

see comments

@iSazonov
Copy link
Collaborator

@bergmeister Could you please correct the PR title and description?

@bergmeister bergmeister changed the title Make it easier to build an installer locally and document it Make it easier to build an installable package locally for WiX development and document it Nov 19, 2017
@bergmeister
Copy link
Contributor Author

bergmeister commented Nov 19, 2017

@iSazonov OK. I've adapted the title and description now to make it clearer that it is about WiX development where one does care too much what exactly lands in the package.

@SteveL-MSFT
Copy link
Member

Thinking further about this, I think I prefer not exposing New-MSIPackage and treat that as an internal function. Have users use Start-PSPackage (so a single way to create msi packages rather than two ways). However, we can update Start-PSPackage to automatically create a PSDrive to resolve the "root folder" requirement (to not expose "private" folder path information) and use that.

@bergmeister
Copy link
Contributor Author

@SteveL-MSFT If you do not want to expose New-MSIPackage any more, then an alternative would be to remove it from the manifest in CmdletsToExport and then only insiders would import the psm1 instead of the psd1 instead. WDYT?

@bergmeister bergmeister reopened this Nov 20, 2017
@SteveL-MSFT
Copy link
Member

I think we should remove New-MSIPackage from exported cmdlets

Import-Module .\build.psm1
Start-PSBuild
Import-Module .\tools\packaging\packaging.psd1
Import-Module .\tools\packaging\packaging.psm1
Copy link
Member

Choose a reason for hiding this comment

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

this line is no longer needed since it's part of packaging.psm1 already

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see what you mean but the idea was to provide a copy-pasteable example that works out of the box. Would it be OK to rather squash the initialization as Import-Module .\build.psm1; Start-PSBuild; Import-Module .\tools\packaging\packaging.psm1? Otherwise I'll of course remove the line if you insist.

Copy link
Member

Choose a reason for hiding this comment

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

For the comment based help, you would only see that if you already have the packaging module loaded, so it just seems weird. I think if you want to provide an easy cut-paste, perhaps it's better to have it in https://github.com/PowerShell/PowerShell/blob/master/docs/building/windows-core.md

cd $RootPathOfPowerShellCheckout
Import-Module .\build.psm1
Start-PSBuild
Import-Module .\tools\packaging\packaging.psm1
Copy link
Member

Choose a reason for hiding this comment

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

Just point to import the folder as a module.

@iSazonov
Copy link
Collaborator

@bergmeister Please resolve merge conflicts.

@bergmeister bergmeister changed the title Make it easier to build an installable package locally for WiX development and document it WIP Make it easier to build an installable package locally for WiX development and document it Jan 10, 2018
@bergmeister
Copy link
Contributor Author

bergmeister commented Jan 10, 2018

Ok, thanks for letting me know. I will come back to it soon (but not today) since it needs more time carefully extracting the diff because the conflict is quite horrible due to the move of a function that has received updates in the meantime. Maybe even a new PR with 2 separate commits (one with the improvements and one with the move) might be better to avoid accidentally reverting code changes. What do you think?

@iSazonov
Copy link
Collaborator

@bergmeister Perhaps easy make new PR.

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.

5 participants