@@ -15,16 +15,15 @@ function Get-BuildConfiguration {
1515
1616 if (Test-Path $resolvedPath - PathType Container) {
1717 $fileNamePath = Join-Path - Path $resolvedPath - ChildPath $ConfigurationFileName
18- }
19- else {
18+ } else {
2019 $fileName = Split-Path - Path $resolvedPath - Leaf
2120 if ($fileName -ne $ConfigurationFileName ) {
2221 throw " $ConfigurationFileName not found in provided pathname: $resolvedPath "
2322 }
2423 $fileNamePath = $resolvedPath
2524 }
2625
27- if (! (Test-Path - Path $fileNamePath - PathType Leaf)) {
26+ if (-not (Test-Path - Path $fileNamePath - PathType Leaf)) {
2827 throw " $ConfigurationFileName not found at path: $resolvedPath "
2928 }
3029
@@ -37,8 +36,7 @@ function Get-BuildConfiguration {
3736 $configObj.BuildOutputPath = Join-Path $projectRoot - ChildPath $configObj.BuildOutputPath
3837 if ($configObj.SignedOutputPath ) {
3938 $configObj.SignedOutputPath = Join-Path $projectRoot - ChildPath $configObj.SignedOutputPath
40- }
41- else {
39+ } else {
4240 $configObj | Add-Member - MemberType NoteProperty - Name SignedOutputPath - Value (Join-Path $projectRoot - ChildPath ' signed' )
4341 }
4442
@@ -48,26 +46,25 @@ function Get-BuildConfiguration {
4846function Invoke-ModuleBuild {
4947 [CmdletBinding ()]
5048 param (
51- [Parameter (Mandatory = $true )]
49+ [Parameter (Mandatory = $true )]
5250 [ScriptBlock ] $BuildScript
5351 )
5452
55- Write-Verbose - Verbose - Message " Invoking build script"
53+ Write-Verbose - Verbose - Message ' Invoking build script'
5654
5755 $BuildScript.Invoke ()
5856
59- Write-Verbose - Verbose - Message " Finished invoking build script"
57+ Write-Verbose - Verbose - Message ' Finished invoking build script'
6058}
6159
62- function Publish-ModulePackage
63- {
60+ function Publish-ModulePackage {
6461 [CmdletBinding ()]
6562 param (
6663 [Parameter ()]
6764 [Switch ] $Signed
6865 )
6966
70- Write-Verbose - Verbose - Message " Creating new local package repo"
67+ Write-Verbose - Verbose - Message ' Creating new local package repo'
7168 $localRepoName = ' packagebuild-local-repo'
7269 $localRepoLocation = Join-Path - Path ([System.io.path ]::GetTempPath()) - ChildPath $localRepoName
7370 if (Test-Path - Path $localRepoLocation ) {
@@ -80,16 +77,16 @@ function Publish-ModulePackage
8077
8178 Write-Verbose - Verbose - Message " Publishing package to local repo: $localRepoName "
8279 $config = Get-BuildConfiguration
83- if (! $Signed.IsPresent ) {
80+ if (-not $Signed.IsPresent ) {
8481 $modulePath = Join-Path - Path $config.BuildOutputPath - ChildPath $config.ModuleName
8582 } else {
8683 $modulePath = Join-Path - Path $config.SignedOutputPath - ChildPath $config.ModuleName
8784 }
8885 Publish-PSResource - Path $modulePath - Repository $localRepoName - SkipDependenciesCheck - Confirm:$false - Verbose
8986
9087 if ($env: TF_BUILD ) {
91- Write-Verbose - Verbose - Message " Uploading module nuget package artifact to AzDevOps"
92- $artifactName = " nupkg"
88+ Write-Verbose - Verbose - Message ' Uploading module nuget package artifact to AzDevOps'
89+ $artifactName = ' nupkg'
9390 $artifactPath = (Get-ChildItem - Path $localRepoLocation - Filter " $ ( $config.ModuleName ) *.nupkg" ).FullName
9491 $artifactPath = Resolve-Path - Path $artifactPath
9592 Write-Host " ##vso[artifact.upload containerfolder=$artifactName ;artifactname=$artifactName ;]$artifactPath "
@@ -102,36 +99,36 @@ function Publish-ModulePackage
10299function Install-ModulePackageForTest {
103100 [CmdletBinding ()]
104101 param (
105- [Parameter (Mandatory = $true )]
102+ [Parameter (Mandatory = $true )]
106103 [string ] $PackagePath
107104 )
108105
109106 $config = Get-BuildConfiguration
110107
111108 $localRepoName = ' packagebuild-local-repo'
112- $packagePathWithNupkg = Join-Path - Path $PackagePath - ChildPath " nupkg"
109+ $packagePathWithNupkg = Join-Path - Path $PackagePath - ChildPath ' nupkg'
113110 Write-Verbose - Verbose - Message " Registering local package repo: $localRepoName to path: $packagePathWithNupkg "
114111 Register-PSResourceRepository - Name $localRepoName - Uri $packagePathWithNupkg - Trusted - Force
115112
116113 $installationPath = $config.BuildOutputPath
117- if ( ! (Test-Path $installationPath )) {
114+ if (-not (Test-Path - Path $installationPath )) {
118115 Write-Verbose - Verbose - Message " Creating module directory location for tests: $installationPath "
119116 $null = New-Item - Path $installationPath - ItemType Directory - Verbose
120117 }
121118
122119 Write-Verbose - Verbose - Message " Installing module $ ( $config.ModuleName ) to build output path $installationPath "
123- $psgetModuleBase = (get-command save-psresource ).Module.ModuleBase
124- $psgetVersion = (get-command save-psresource ).Module.Version.ToString()
125- $psgetPrerelease = (get-command find-psresource ).module.PrivateData.PSData.Prerelease
120+ $psgetModuleBase = (Get-Command save-psresource ).Module.ModuleBase
121+ $psgetVersion = (Get-Command save-psresource ).Module.Version.ToString()
122+ $psgetPrerelease = (Get-Command find-psresource ).module.PrivateData.PSData.Prerelease
126123 Write-Verbose - Verbose - Message " PSResourceGet module base imported: $psgetModuleBase "
127124 Write-Verbose - Verbose - Message " PSResourceGet version base imported: $psgetVersion "
128125 Write-Verbose - Verbose - Message " PSResourceGet prerelease base imported: $psgetPrerelease "
129126 # Save-PSResource -Name $config.ModuleName -Repository $localRepoName -Path $installationPath -SkipDependencyCheck -Prerelease -Confirm:$false -TrustRepository
130127
131128 Register-PSRepository - Name $localRepoName - SourceLocation $packagePathWithNupkg - InstallationPolicy Trusted - Verbose
132- $psgetv2ModuleBase = (get-command save-module ).Module.ModuleBase
133- $psgetv2Version = (get-command save-module ).Module.Version.ToString()
134- $psgetv2Prerelease = (get-command save-module ).module.PrivateData.PSData.Prerelease
129+ $psgetv2ModuleBase = (Get-Command save-module ).Module.ModuleBase
130+ $psgetv2Version = (Get-Command save-module ).Module.Version.ToString()
131+ $psgetv2Prerelease = (Get-Command save-module ).module.PrivateData.PSData.Prerelease
135132 Write-Verbose - Verbose - Message " PowerShellGet module base imported: $psgetv2ModuleBase "
136133 Write-Verbose - Verbose - Message " PowerShellGet version base imported: $psgetv2Version "
137134 Write-Verbose - Verbose - Message " PowerShellGet prerelease base imported: $psgetv2Prerelease "
@@ -145,14 +142,14 @@ function Install-ModulePackageForTest {
145142function Invoke-ModuleTestsACR {
146143 [CmdletBinding ()]
147144 param (
148- [ValidateSet (" Functional" , " StaticAnalysis" )]
149- [string []] $Type = " Functional"
145+ [ValidateSet (' Functional' , ' StaticAnalysis' )]
146+ [string []] $Type = ' Functional'
150147 )
151148
152149 $acrTestFiles = @ (
153- " FindPSResourceTests/FindPSResourceContainerRegistryServer.Tests.ps1" ,
154- " InstallPSResourceTests/InstallPSResourceContainerRegistryServer.Tests.ps1" ,
155- " PublishPSResourceTests/PublishPSResourceContainerRegistryServer.Tests.ps1"
150+ ' FindPSResourceTests/FindPSResourceContainerRegistryServer.Tests.ps1' ,
151+ ' InstallPSResourceTests/InstallPSResourceContainerRegistryServer.Tests.ps1' ,
152+ ' PublishPSResourceTests/PublishPSResourceContainerRegistryServer.Tests.ps1'
156153 )
157154
158155 Invoke-ModuleTests - Type $Type - TestFilePath $acrTestFiles
@@ -162,12 +159,12 @@ function Invoke-ModuleTestsACR {
162159function Invoke-ModuleTests {
163160 [CmdletBinding ()]
164161 param (
165- [ValidateSet (" Functional" , " StaticAnalysis" )]
166- [string []] $Type = " Functional" ,
167- [string []] $TestFilePath = " . "
162+ [ValidateSet (' Functional' , ' StaticAnalysis' )]
163+ [string []] $Type = ' Functional' ,
164+ [string []] $TestFilePath = ' . '
168165 )
169166
170- Write-Verbose - Verbose - Message " Starting module Pester tests..."
167+ Write-Verbose - Verbose - Message ' Starting module Pester tests...'
171168
172169 # Run module Pester tests.
173170 $config = Get-BuildConfiguration
@@ -176,12 +173,11 @@ function Invoke-ModuleTests {
176173 $testResultFileName = ' result.pester.xml'
177174 $testPath = $config.TestPath
178175 Write-Verbose - Verbose $config.ModuleName
179- $moduleToTest = Join-Path - Path $config.BuildOutputPath - ChildPath " Microsoft.PowerShell.PSResourceGet"
176+ $moduleToTest = Join-Path - Path $config.BuildOutputPath - ChildPath ' Microsoft.PowerShell.PSResourceGet'
180177
181178 if ($TestFilePath.Count -gt 1 ) {
182179 $TestFilePathJoined = $TestFilePath -join ' ,'
183- }
184- else {
180+ } else {
185181 $TestFilePathJoined = $TestFilePath
186182 }
187183
@@ -192,9 +188,8 @@ function Invoke-ModuleTests {
192188
193189 try {
194190 & $pwshExePath - NoProfile - NoLogo - Command $command
195- }
196- catch {
197- Write-Error - Message " Error invoking module Pester tests."
191+ } catch {
192+ Write-Error - Message ' Error invoking module Pester tests.'
198193 }
199194
200195 $testResultsFilePath = Join-Path - Path $testPath - ChildPath $testResultFileName
@@ -203,7 +198,7 @@ function Invoke-ModuleTests {
203198 # and class it references to do so can't be found. This will be fixed later.
204199
205200 # # Examine Pester test results.
206- # if (! (Test-Path -Path $testResultsFilePath)) {
201+ # if (-not (Test-Path -Path $testResultsFilePath)) {
207202 # throw "Module test result file not found: '$testResultsFilePath'"
208203 # }
209204 # $xmlDoc = [xml] (Get-Content -Path $testResultsFilePath -Raw)
@@ -219,7 +214,7 @@ function Invoke-ModuleTests {
219214
220215 # Publish test results to AzDevOps
221216 if ($env: TF_BUILD ) {
222- Write-Verbose - Verbose - Message " Uploading test results to AzDevOps"
217+ Write-Verbose - Verbose - Message ' Uploading test results to AzDevOps'
223218 $powerShellName = if ($PSVersionTable.PSEdition -eq ' Core' ) { ' PowerShell Core' } else { ' Windows PowerShell' }
224219 $TestType = ' NUnit'
225220 $Title = " Functional Tests - $env: AGENT_OS - $powershellName Results"
@@ -229,7 +224,7 @@ function Invoke-ModuleTests {
229224 Write-Host " ##$message "
230225 }
231226
232- Write-Verbose - Verbose - Message " Module Pester tests complete."
227+ Write-Verbose - Verbose - Message ' Module Pester tests complete.'
233228}
234229
235230function Show-PSPesterError {
@@ -242,9 +237,9 @@ function Show-PSPesterError {
242237 $description = $testFailure.description
243238 $name = $testFailure.name
244239 $message = $testFailure.failure.message
245- $stackTrace = $testFailure.failure ." stack-trace"
240+ $stackTrace = $testFailure.failure .' stack-trace'
246241
247- $fullMsg = " `n {0}`n {1}`n {2}`n {3}`{4}" -f (" Description: " + $description ), (" Name: " + $name ), " message:" , $message , " stack-trace:" , $stackTrace
242+ $fullMsg = " `n {0}`n {1}`n {2}`n {3}`{4}" -f (' Description: ' + $description ), (' Name: ' + $name ), ' message:' , $message , ' stack-trace:' , $stackTrace
248243
249244 Write-Error $fullMsg
250245}
0 commit comments