Skip to content
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.

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

Simplify build scripts even more and upgrade platyPS in Appveyor #1088

Merged
merged 17 commits into from
Jan 16, 2019

Conversation

bergmeister
Copy link
Collaborator

@bergmeister bergmeister commented Oct 23, 2018

PR Summary

This is a follow up of PR #1082 that improves it by further simplifying and tidying up the build scripts.
Especially: removing the $framework parameter as we can figure it out ourselves, upgrade platyPS version installed in AppVeyor for security (see here)

PR Checklist

Copy link
Contributor

@rjmholt rjmholt left a comment

Choose a reason for hiding this comment

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

LGTM! Left a couple of comments, but nothing blocking.

build.psm1 Outdated
#$modInfo = new-object Microsoft.PowerShell.Commands.ModuleSpecification -ArgumentList @{ ModuleName = "platyps"; ModuleVersion = $requiredVersionOfplatyPS}
#if ( $null -eq (Get-Module -ListAvailable -FullyQualifiedName $modInfo))
if ( $null -eq (Get-Module -ListAvailable platyPS))
if ( $null -eq (Get-Module -ListAvailable platyPS) -or ((Get-Module -ListAvailable platyPS | Select-Object -First 1).Version -lt [version]0.12))
Copy link
Contributor

@rjmholt rjmholt Nov 5, 2018

Choose a reason for hiding this comment

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

Style: Got a space on the left of the $null but no space on the right of the 0.12.

gmo -List is being called twice here and only looks at the first module (gmo -List returns module in essentially random order, so that might not be the check we want).

Maybe something like:

$platyPS = Get-Module -ListAvailable @{ ModuleName = 'platyPS'; ModuleVersion = '0.12' } `
    | Sort-Object Version `
    | Select-Object -First 1

if (-not $platyPS)
{
    Write-Verbose -verbose "platyPS module not found or below required version of 0.12, installing the latest version."
    Install-Module -Force -Name platyPS -Scope CurrentUser
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Refactored that slightly to use a FullyQualifiedName

Copy link
Collaborator Author

@bergmeister bergmeister Dec 19, 2018

Choose a reason for hiding this comment

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

Sorry, but Get-Module -ListAvailable @{ ModuleName = 'platyPS'; ModuleVersion = '0.12.0' } does not work on my machine using either WPS or PSCore, I will refactor it to call gmo only once though and sort by version. This shows that gmo could benefit from -MinimumVersion parameter. P.S. Sort-Object Version also needs the Descending switch to get the latest version, otherwise it'd be the earliest.

build.psm1 Outdated
$destinationDirBinaries = "$destinationDir\coreclr"
}
elseif ($PSVersion -eq '3') {
if ($PSVersion -eq '3') {
Copy link
Contributor

Choose a reason for hiding this comment

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

$PSVersion above is compared to an [int] rather than a [string] -- I know they work out the same though :)

Copy link
Contributor

Choose a reason for hiding this comment

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

This if/elseif/else might be a good candidate for a switch maybe:

switch ($PSVersion)
{
    3
    {
    }

    4
    {
    }

    5
    {
    }

    default
    {
    }
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks, point taken. I'll change it to a switch for 3,4,5 and 6 and throw otherwise

build.psm1 Outdated
# The Rules project has a dependency on the Engine therefore just building the Rules project is enough
$config = "PSV${PSVersion}${Configuration}"
try {
Push-Location $projectRoot/Rules
Write-Progress "Building ScriptAnalyzer '$framework' version '${PSVersion}' configuration '${Configuration}'"
$buildOutput = dotnet build Rules.csproj --framework $frameworkName --configuration "${config}"
Write-Progress "Building ScriptAnalyzer for PSVersion '$PSVersion' using framework '$framework' and configuration '$config'"
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see a change in variables $config or $Configuration in the script -- just want to check you don't mean $Configuration here.

Copy link
Collaborator Author

@bergmeister bergmeister Dec 19, 2018

Choose a reason for hiding this comment

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

$Configuration is the high level Debug\Release variable that the end user uses when calling the build script, internally, the actual configuration passed to msbuild is $config, which can be different and is e.g. PSV3Release for WMF3. I thought logging the actual low level variable was better, but looking at it now, I am probably wrong and will change it back to $Configuration

build.psm1 Outdated
Write-Progress "Building ScriptAnalyzer '$framework' version '${PSVersion}' configuration '${Configuration}'"
$buildOutput = dotnet build Rules.csproj --framework $frameworkName --configuration "${config}"
Write-Progress "Building ScriptAnalyzer for PSVersion '$PSVersion' using framework '$framework' and configuration '$config'"
$buildOutput = dotnet build --framework $framework --configuration "${config}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be worth taking the ${config} out of brackets here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, this was a James-ism ;-)

@rjmholt
Copy link
Contributor

rjmholt commented Nov 5, 2018

@JamesWTruher gentle ping on the review request

Copy link
Member

@JamesWTruher JamesWTruher left a comment

Choose a reason for hiding this comment

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

rob makes a couple good points (esp wrt multiple calls to get-module), so it would be good to address those.
thanks for doing this, I'll abandon my similar changes :)

@bergmeister
Copy link
Collaborator Author

bergmeister commented Dec 19, 2018

Ok, I addressed all points and added one more improvement, which is to build docs automatically the first time if the doc file does not exist and then do not always build docs, the behaviour of the Documentation parameter it therefore similar to the -ResGen parameter on Start-PSBuild. In another PR, I'd also like to get rid of the parameter sets in build.ps1 to allow combining switches like e.g. Clean or Test.
Merge is now only being blocked by the build failure on Linux due to the AppVeyor image update. PR #1107 has the best possible workaround for that atm, can you please review this one @rjmholt while James is out of office?

@bergmeister bergmeister merged commit 7a9d45d into PowerShell:development Jan 16, 2019
bergmeister added a commit to bergmeister/PSScriptAnalyzer that referenced this pull request Mar 5, 2019
…erShell#1088)

* simplify build scripts even more and upgrade platyPS in Appveyor

* add check for minimum version of platyps

* fix ci and remove other leftovers

* fix appveyor core build

* fix wmf4 build by including the newtonsoft dll

* fix syntax

* trigger ci

* trigger ci

* address PR comments

* build docs automatically the first time to simplify build process and save time on rebuild and get rid of unnecessary low level parameter sets

* revert accidentally checked in file

* fix merge/integration problem when merging from upstream

* Fix another merge problem due to variable rename
bergmeister added a commit to bergmeister/PSScriptAnalyzer that referenced this pull request Mar 22, 2019
…erShell#1088)

* simplify build scripts even more and upgrade platyPS in Appveyor

* add check for minimum version of platyps

* fix ci and remove other leftovers

* fix appveyor core build

* fix wmf4 build by including the newtonsoft dll

* fix syntax

* trigger ci

* trigger ci

* address PR comments

* build docs automatically the first time to simplify build process and save time on rebuild and get rid of unnecessary low level parameter sets

* revert accidentally checked in file

* fix merge/integration problem when merging from upstream

* Fix another merge problem due to variable rename
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants