Working with Build Options

This commit is contained in:
Wes Carroll
2019-03-27 18:19:50 -04:00
parent 9ff003bbe0
commit 2eaba75318
4 changed files with 157 additions and 12 deletions
+51 -12
View File
@@ -1,17 +1,45 @@
task . InstallDependencies, Analyze
#Requires -Modules 'InvokeBuild'
task InstallDependencies {
Install-Module Pester -Force
Install-Module PSScriptAnalyzer -Force
. '.\ZertoApiWrapper.settings.ps1'
import-module .\ZertoApiWrapper\ZertoApiWrapper.psd1
[CmdletBinding()]
param([switch]$Install,
[string]$Configuration = (property Configuration Release))
$targetDir = "temp/$Configuration/ZertoApiWrapper"
task . Analyze
<# Synopsis: Ensure platyPS is installed #>
task CheckPlatyPSInstalled {
if ($null -eq (Get-Module -List platyPS)) {
Install-Module -Scope CurrentUser -Repository PSGallery -Name platyPS
}
}
task Analyze {
<# Synopsis: Ensure Pester is installed #>
task CheckPesterInstalled {
if ($null -eq (Get-Module -List Pester)) {
Install-Module -Scope CurrentUser -Repository PSGallery -Name Pester
}
}
<# Synopsis: Ensure PSScriptAnalyzer is installed #>
task CheckPSScriptAnalyzerInstalled {
if ($null -eq (Get-Module -List PSScriptAnalyzer)) {
Install-Module -Scope CurrentUser -Repository PSGallery -Name PSScriptAnalyzer
}
}
<# Synopsis: Analyze ZertoApiWrapper functions for Code Violations #>
task Analyze CheckPSScriptAnalyzerInstalled, CheckPesterInstalled, CheckPlatyPSInstalled, {
$scriptAnalyzerParams = @{
Path = "$BuildRoot\ZertoApiWrapper\"
Severity = @('Error', 'Warning')
Recurse = $true
Verbose = $false
ExcludeRule = 'PSUseDeclaredVarsMoreThanAssignments'
ExcludeRule = @('PSUseDeclaredVarsMoreThanAssignments', 'PSUseShouldProcessForStateChangingFunctions')
}
$saresults = Invoke-ScriptAnalyzer @scriptAnalyzerParams
@@ -21,12 +49,23 @@ task Analyze {
}
}
task FileTests {
Invoke-Pester "$BuildRoot\Tests\Public\ZertoApiWrapper.Tests.ps1"
$buildMamlParams = @{
Inputs = { Get-ChildItem docs/*.md }
Outputs = "$targetDir/en-us/ZertoApiWrapper-help.xml"
}
task BuildPsd1 {
$functionsToExportPath = "{0}\ZertoApiWrapper\Public\" -f $MyInvocation.MyCommand.PSPath
$functionsToExport = (Get-ChildItem -Path $functionsToExportPath -File).name.Replace('.ps1', '')
$functionsToExport
task BuildMamlHelp @buildMamlParams {
platyPS\New-ExternalHelp .\docs -Force -OutputPath $buildMamlParams.Outputs
}
task FileTests CheckPesterInstalled, {
Invoke-Pester "$BuildRoot\Tests\Public\ZertoApiWrapper.Tests.ps1" -Show Fails
}
task UpdateModuleManifest {
$functionsToExportPath = "$BuildRoot\ZertoApiWrapper\Public\"
$functionsToExport = (Get-ChildItem -Path $functionsToExportPath -File).name.Replace('.ps1', '')
$version = Get-Module -Name ZertoApiWrapper | select Version
$buildVersion = $version.Build
}