@@ -114,7 +114,7 @@ function Start-DocumentationBuild
114
114
{
115
115
throw " Cannot find markdown documentation folder."
116
116
}
117
- Import-Module platyPS
117
+ Import-Module platyPS - Verbose: $false
118
118
if ( -not (Test-Path $outputDocsPath )) {
119
119
$null = New-Item - Type Directory - Path $outputDocsPath - Force
120
120
}
@@ -150,7 +150,9 @@ function Start-ScriptAnalyzerBuild
150
150
[ValidateSet (" Debug" , " Release" )]
151
151
[string ]$Configuration = " Debug" ,
152
152
153
- [switch ]$Documentation
153
+ [switch ]$Documentation ,
154
+
155
+ [switch ]$Catalog
154
156
)
155
157
156
158
BEGIN {
@@ -163,27 +165,36 @@ function Start-ScriptAnalyzerBuild
163
165
$foundVersion = Get-InstalledCLIVersion
164
166
Write-Warning " No suitable dotnet CLI found, requires version '$requiredVersion ' found only '$foundVersion '"
165
167
}
168
+ $verboseWanted = $false
169
+ if ( $PSBoundParameters [' Verbose' ] ) {
170
+ $verboseWanted = $PSBoundParameters [' Verbose' ].ToBool()
171
+ }
166
172
}
167
173
END {
168
174
169
175
# Build docs either when -Documentation switch is being specified or the first time in a clean repo
170
176
$documentationFileExists = Test-Path (Join-Path $PSScriptRoot ' out\PSScriptAnalyzer\en-us\Microsoft.Windows.PowerShell.ScriptAnalyzer.dll-Help.xml' )
171
177
if ( $Documentation -or -not $documentationFileExists )
172
178
{
173
- Start-DocumentationBuild
179
+ Write-Verbose - Verbose:$verboseWanted - Message " Start-DocumentationBuild"
180
+ Start-DocumentationBuild - Verbose:$verboseWanted
174
181
}
175
182
176
183
if ( $All )
177
184
{
178
185
# Build all the versions of the analyzer
179
186
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
181
191
}
182
192
return
183
193
}
184
194
185
195
if (-not $profilesCopied )
186
196
{
197
+ Write-Verbose - Verbose:$verboseWanted - Message " Copy-CompatibilityProfiles"
187
198
Copy-CompatibilityProfiles
188
199
# Set the variable in the caller's scope, so this will only happen once
189
200
Set-Variable - Name profilesCopied - Value $true - Scope 1
@@ -253,12 +264,24 @@ function Start-ScriptAnalyzerBuild
253
264
# The Rules project has a dependency on the Engine therefore just building the Rules project is enough
254
265
try {
255
266
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 "
257
270
if ( -not $script :DotnetExe ) {
258
271
$script :DotnetExe = Get-DotnetExe
259
272
}
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
261
283
if ( $LASTEXITCODE -ne 0 ) { throw " $buildOutput " }
284
+ Write-Verbose - Verbose:$verboseWanted - message " $buildOutput "
262
285
}
263
286
catch {
264
287
Write-Warning $_
@@ -271,24 +294,57 @@ function Start-ScriptAnalyzerBuild
271
294
272
295
Publish-File $itemsToCopyCommon $script :destinationDir
273
296
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
+ }
279
311
Publish-File $itemsToCopyBinaries $destinationDirBinaries
280
312
281
313
$settingsFiles = Get-Childitem " $projectRoot \Engine\Settings" | ForEach-Object - MemberName FullName
282
314
Publish-File $settingsFiles (Join-Path - Path $script :destinationDir - ChildPath Settings)
283
315
284
316
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
286
324
}
287
325
288
326
Pop-Location
289
327
}
290
328
}
291
329
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
+
292
348
# TEST HELPERS
293
349
# Run our tests
294
350
function Test-ScriptAnalyzer
0 commit comments