@@ -114,7 +114,7 @@ function Start-DocumentationBuild
114114 {
115115 throw " Cannot find markdown documentation folder."
116116 }
117- Import-Module platyPS
117+ Import-Module platyPS - Verbose: $false
118118 if ( -not (Test-Path $outputDocsPath )) {
119119 $null = New-Item - Type Directory - Path $outputDocsPath - Force
120120 }
@@ -150,7 +150,9 @@ function Start-ScriptAnalyzerBuild
150150 [ValidateSet (" Debug" , " Release" )]
151151 [string ]$Configuration = " Debug" ,
152152
153- [switch ]$Documentation
153+ [switch ]$Documentation ,
154+
155+ [switch ]$Catalog
154156 )
155157
156158 BEGIN {
@@ -163,27 +165,36 @@ function Start-ScriptAnalyzerBuild
163165 $foundVersion = Get-InstalledCLIVersion
164166 Write-Warning " No suitable dotnet CLI found, requires version '$requiredVersion ' found only '$foundVersion '"
165167 }
168+ $verboseWanted = $false
169+ if ( $PSBoundParameters [' Verbose' ] ) {
170+ $verboseWanted = $PSBoundParameters [' Verbose' ].ToBool()
171+ }
166172 }
167173 END {
168174
169175 # Build docs either when -Documentation switch is being specified or the first time in a clean repo
170176 $documentationFileExists = Test-Path (Join-Path $PSScriptRoot ' out\PSScriptAnalyzer\en-us\Microsoft.Windows.PowerShell.ScriptAnalyzer.dll-Help.xml' )
171177 if ( $Documentation -or -not $documentationFileExists )
172178 {
173- Start-DocumentationBuild
179+ Write-Verbose - Verbose:$verboseWanted - Message " Start-DocumentationBuild"
180+ Start-DocumentationBuild - Verbose:$verboseWanted
174181 }
175182
176183 if ( $All )
177184 {
178185 # Build all the versions of the analyzer
179186 foreach ($psVersion in 3 .. 7 ) {
180- Start-ScriptAnalyzerBuild - Configuration $Configuration - PSVersion $psVersion
187+ Start-ScriptAnalyzerBuild - Configuration $Configuration - PSVersion $psVersion - Verbose:$verboseWanted
188+ }
189+ if ( $Catalog ) {
190+ New-Catalog - Location $script :destinationDir
181191 }
182192 return
183193 }
184194
185195 if (-not $profilesCopied )
186196 {
197+ Write-Verbose - Verbose:$verboseWanted - Message " Copy-CompatibilityProfiles"
187198 Copy-CompatibilityProfiles
188199 # Set the variable in the caller's scope, so this will only happen once
189200 Set-Variable - Name profilesCopied - Value $true - Scope 1
@@ -253,12 +264,24 @@ function Start-ScriptAnalyzerBuild
253264 # The Rules project has a dependency on the Engine therefore just building the Rules project is enough
254265 try {
255266 Push-Location $projectRoot / Rules
256- Write-Progress " Building ScriptAnalyzer for PSVersion '$PSVersion ' using framework '$framework ' and configuration '$Configuration '"
267+ $message = " Building ScriptAnalyzer for PSVersion '$PSVersion ' using framework '$framework ' and configuration '$Configuration '"
268+ Write-Verbose - Verbose:$verboseWanted - Message " $message "
269+ Write-Progress " $message "
257270 if ( -not $script :DotnetExe ) {
258271 $script :DotnetExe = Get-DotnetExe
259272 }
260- $buildOutput = & $script :DotnetExe build -- framework $framework -- configuration " $buildConfiguration " 2>&1
273+ $dotnetArgs = " build" ,
274+ " --framework" ,
275+ $framework ,
276+ " --configuration" ,
277+ " $buildConfiguration "
278+ if ( $env: TF_BUILD ) {
279+ $dotnetArgs += " --output"
280+ $dotnetArgs += " ${PSScriptRoot} \bin\${buildConfiguration} \${framework} "
281+ }
282+ $buildOutput = & $script :DotnetExe $dotnetArgs 2>&1
261283 if ( $LASTEXITCODE -ne 0 ) { throw " $buildOutput " }
284+ Write-Verbose - Verbose:$verboseWanted - message " $buildOutput "
262285 }
263286 catch {
264287 Write-Warning $_
@@ -271,24 +294,57 @@ function Start-ScriptAnalyzerBuild
271294
272295 Publish-File $itemsToCopyCommon $script :destinationDir
273296
274- $itemsToCopyBinaries = @ (
275- " $projectRoot \Engine\bin\${buildConfiguration} \${Framework} \Microsoft.Windows.PowerShell.ScriptAnalyzer.dll" ,
276- " $projectRoot \Rules\bin\${buildConfiguration} \${Framework} \Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.dll"
277- " $projectRoot \Rules\bin\${buildConfiguration} \${framework} \Microsoft.PowerShell.CrossCompatibility.dll"
278- )
297+ if ( $env: TF_BUILD ) {
298+ $itemsToCopyBinaries = @ (
299+ " $projectRoot \bin\${buildConfiguration} \${Framework} \Microsoft.Windows.PowerShell.ScriptAnalyzer.dll" ,
300+ " $projectRoot \bin\${buildConfiguration} \${Framework} \Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.dll"
301+ " $projectRoot \bin\${buildConfiguration} \${framework} \Microsoft.PowerShell.CrossCompatibility.dll"
302+ )
303+ }
304+ else {
305+ $itemsToCopyBinaries = @ (
306+ " $projectRoot \Engine\bin\${buildConfiguration} \${Framework} \Microsoft.Windows.PowerShell.ScriptAnalyzer.dll" ,
307+ " $projectRoot \Rules\bin\${buildConfiguration} \${Framework} \Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.dll"
308+ " $projectRoot \Rules\bin\${buildConfiguration} \${framework} \Microsoft.PowerShell.CrossCompatibility.dll"
309+ )
310+ }
279311 Publish-File $itemsToCopyBinaries $destinationDirBinaries
280312
281313 $settingsFiles = Get-Childitem " $projectRoot \Engine\Settings" | ForEach-Object - MemberName FullName
282314 Publish-File $settingsFiles (Join-Path - Path $script :destinationDir - ChildPath Settings)
283315
284316 if ($framework -eq ' net452' ) {
285- Copy-Item - path " $projectRoot \Rules\bin\${buildConfiguration} \${framework} \Newtonsoft.Json.dll" - Destination $destinationDirBinaries
317+ if ( $env: TF_BUILD ) {
318+ $nsoft = " $projectRoot \bin\${buildConfiguration} \${framework} \Newtonsoft.Json.dll"
319+ }
320+ else {
321+ $nsoft = " $projectRoot \Rules\bin\${buildConfiguration} \${framework} \Newtonsoft.Json.dll"
322+ }
323+ Copy-Item - path $nsoft - Destination $destinationDirBinaries
286324 }
287325
288326 Pop-Location
289327 }
290328}
291329
330+ function New-Catalog
331+ {
332+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute (' PSUseCompatibleCommands' , ' ' )]
333+ param ( [Parameter ()]$Location )
334+ $newFileCatalog = Get-Command - ErrorAction SilentlyContinue New-FileCatalog
335+ if ($null -eq $newFileCatalog ) {
336+ Write-Warning " New-FileCatalog not found, not creating catalog"
337+ return
338+ }
339+ try {
340+ Push-Location $Location
341+ New-FileCatalog - CatalogFilePath PSScriptAnalyzer.cat - Path .
342+ }
343+ finally {
344+ Pop-Location
345+ }
346+ }
347+
292348# TEST HELPERS
293349# Run our tests
294350function Test-ScriptAnalyzer
0 commit comments