Skip to content

Commit

Permalink
Switch-over to using PSResourceGet to bootstrap the required modules
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesDawson committed May 16, 2024
1 parent 2d52a2b commit adf910b
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#requires -Version 7.4
<#
.SYNOPSIS
Runs a .NET flavoured build process.
Expand Down Expand Up @@ -71,13 +72,13 @@ param (
[string] $BuildModulePath,

[Parameter()]
[version] $BuildModuleVersion = "1.5.6",
[string] $BuildModuleVersion = "1.5.6",

[Parameter()]
[string] $BuildModulePackageVersion = $BuildModuleVersion,
[switch] $BuildModulePreReleaseVersion,

[Parameter()]
[version] $InvokeBuildModuleVersion = "5.10.3"
[string] $InvokeBuildModuleVersion = "5.10.3"
)

$ErrorActionPreference = $ErrorActionPreference ? $ErrorActionPreference : 'Stop'
Expand All @@ -86,13 +87,10 @@ $InformationPreference = 'Continue'
$here = Split-Path -Parent $PSCommandPath

#region InvokeBuild setup
if (!(Get-Module -ListAvailable InvokeBuild)) {
Install-Module InvokeBuild -RequiredVersion $InvokeBuildModuleVersion -Scope CurrentUser -Force -Repository PSGallery
}
Import-Module InvokeBuild
# This handles calling the build engine when this file is run like a normal PowerShell script
# (i.e. avoids the need to have another script to setup the InvokeBuild environment and issue the 'Invoke-Build' command )
if ($MyInvocation.ScriptName -notlike '*Invoke-Build.ps1') {
Install-PSResource InvokeBuild -Version $InvokeBuildModuleVersion -Scope CurrentUser -TrustRepository -Verbose | Out-Null
try {
Invoke-Build $Tasks $MyInvocation.MyCommand.Path @PSBoundParameters
}
Expand All @@ -106,10 +104,7 @@ if ($MyInvocation.ScriptName -notlike '*Invoke-Build.ps1') {

#region Import shared tasks and initialise build framework
if (!($BuildModulePath)) {
if (!(Get-Module -ListAvailable Endjin.RecommendedPractices.Build | ? { $_.Version -eq $BuildModuleVersion })) {
Write-Information "Installing 'Endjin.RecommendedPractices.Build' module..."
Install-Module Endjin.RecommendedPractices.Build -RequiredVersion $BuildModulePackageVersion -Scope CurrentUser -Force -Repository PSGallery -AllowPrerelease:$($BuildModulePackageVersion -match "-")
}
Install-PSResource Endjin.RecommendedPractices.Build -Version $BuildModuleVersion -Prerelease:$BuildModulePreReleaseVersion -Scope CurrentUser -TrustRepository -Verbose | Out-Null
$BuildModulePath = "Endjin.RecommendedPractices.Build"
}
else {
Expand Down

0 comments on commit adf910b

Please sign in to comment.