-
Notifications
You must be signed in to change notification settings - Fork 388
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
Simplify build scripts even more and upgrade platyPS in Appveyor #1088
Conversation
There was a problem hiding this 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)) |
There was a problem hiding this comment.
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
}
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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') { |
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
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
{
}
}
There was a problem hiding this comment.
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'" |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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}" |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 ;-)
@JamesWTruher gentle ping on the review request |
There was a problem hiding this 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 :)
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 |
… save time on rebuild and get rid of unnecessary low level parameter sets
…nalyzer into upgradePlatyPS # Conflicts: # Utils/ReleaseMaker.psm1 # build.psm1
…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
…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
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
.cs
,.ps1
and.psm1
files have the correct copyright headerWIP:
to the beginning of the title and remove the prefix when the PR is ready.