-
Notifications
You must be signed in to change notification settings - Fork 382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
new build scripts for release pipeline #1442
Changes from all commits
c3c7fdd
272039b
67cc341
db8bed0
2243b62
8ed8171
5ff3bff
eacda3b
c391c7a
dc4653b
52e5818
5d5ae33
2bbd2d5
1462e1b
2fb32d3
f04b6a1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -114,7 +114,7 @@ function Start-DocumentationBuild | |
{ | ||
throw "Cannot find markdown documentation folder." | ||
} | ||
Import-Module platyPS | ||
Import-Module platyPS -Verbose:$false | ||
if ( -not (Test-Path $outputDocsPath)) { | ||
$null = New-Item -Type Directory -Path $outputDocsPath -Force | ||
} | ||
|
@@ -150,7 +150,9 @@ function Start-ScriptAnalyzerBuild | |
[ValidateSet("Debug", "Release")] | ||
[string]$Configuration = "Debug", | ||
|
||
[switch]$Documentation | ||
[switch]$Documentation, | ||
|
||
[switch]$Catalog | ||
) | ||
|
||
BEGIN { | ||
|
@@ -163,27 +165,36 @@ function Start-ScriptAnalyzerBuild | |
$foundVersion = Get-InstalledCLIVersion | ||
Write-Warning "No suitable dotnet CLI found, requires version '$requiredVersion' found only '$foundVersion'" | ||
} | ||
$verboseWanted = $false | ||
if ( $PSBoundParameters['Verbose'] ) { | ||
$verboseWanted = $PSBoundParameters['Verbose'].ToBool() | ||
} | ||
} | ||
END { | ||
|
||
# Build docs either when -Documentation switch is being specified or the first time in a clean repo | ||
$documentationFileExists = Test-Path (Join-Path $PSScriptRoot 'out\PSScriptAnalyzer\en-us\Microsoft.Windows.PowerShell.ScriptAnalyzer.dll-Help.xml') | ||
if ( $Documentation -or -not $documentationFileExists ) | ||
{ | ||
Start-DocumentationBuild | ||
Write-Verbose -Verbose:$verboseWanted -Message "Start-DocumentationBuild" | ||
Start-DocumentationBuild -Verbose:$verboseWanted | ||
} | ||
|
||
if ( $All ) | ||
{ | ||
# Build all the versions of the analyzer | ||
foreach($psVersion in 3..7) { | ||
Start-ScriptAnalyzerBuild -Configuration $Configuration -PSVersion $psVersion | ||
Start-ScriptAnalyzerBuild -Configuration $Configuration -PSVersion $psVersion -Verbose:$verboseWanted | ||
} | ||
if ( $Catalog ) { | ||
New-Catalog -Location $script:destinationDir | ||
} | ||
return | ||
} | ||
|
||
if (-not $profilesCopied) | ||
{ | ||
Write-Verbose -Verbose:$verboseWanted -Message "Copy-CompatibilityProfiles" | ||
Copy-CompatibilityProfiles | ||
# Set the variable in the caller's scope, so this will only happen once | ||
Set-Variable -Name profilesCopied -Value $true -Scope 1 | ||
|
@@ -253,12 +264,24 @@ function Start-ScriptAnalyzerBuild | |
# The Rules project has a dependency on the Engine therefore just building the Rules project is enough | ||
try { | ||
Push-Location $projectRoot/Rules | ||
Write-Progress "Building ScriptAnalyzer for PSVersion '$PSVersion' using framework '$framework' and configuration '$Configuration'" | ||
$message = "Building ScriptAnalyzer for PSVersion '$PSVersion' using framework '$framework' and configuration '$Configuration'" | ||
Write-Verbose -Verbose:$verboseWanted -Message "$message" | ||
Write-Progress "$message" | ||
if ( -not $script:DotnetExe ) { | ||
$script:DotnetExe = Get-DotnetExe | ||
} | ||
$buildOutput = & $script:DotnetExe build --framework $framework --configuration "$buildConfiguration" 2>&1 | ||
$dotnetArgs = "build", | ||
"--framework", | ||
$framework, | ||
"--configuration", | ||
"$buildConfiguration" | ||
if ( $env:TF_BUILD ) { | ||
$dotnetArgs += "--output" | ||
$dotnetArgs += "${PSScriptRoot}\bin\${buildConfiguration}\${framework}" | ||
} | ||
$buildOutput = & $script:DotnetExe $dotnetArgs 2>&1 | ||
if ( $LASTEXITCODE -ne 0 ) { throw "$buildOutput" } | ||
Write-Verbose -Verbose:$verboseWanted -message "$buildOutput" | ||
} | ||
catch { | ||
Write-Warning $_ | ||
|
@@ -271,24 +294,57 @@ function Start-ScriptAnalyzerBuild | |
|
||
Publish-File $itemsToCopyCommon $script:destinationDir | ||
|
||
$itemsToCopyBinaries = @( | ||
"$projectRoot\Engine\bin\${buildConfiguration}\${Framework}\Microsoft.Windows.PowerShell.ScriptAnalyzer.dll", | ||
"$projectRoot\Rules\bin\${buildConfiguration}\${Framework}\Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.dll" | ||
"$projectRoot\Rules\bin\${buildConfiguration}\${framework}\Microsoft.PowerShell.CrossCompatibility.dll" | ||
) | ||
if ( $env:TF_BUILD ) { | ||
$itemsToCopyBinaries = @( | ||
"$projectRoot\bin\${buildConfiguration}\${Framework}\Microsoft.Windows.PowerShell.ScriptAnalyzer.dll", | ||
"$projectRoot\bin\${buildConfiguration}\${Framework}\Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.dll" | ||
"$projectRoot\bin\${buildConfiguration}\${framework}\Microsoft.PowerShell.CrossCompatibility.dll" | ||
) | ||
} | ||
else { | ||
$itemsToCopyBinaries = @( | ||
"$projectRoot\Engine\bin\${buildConfiguration}\${Framework}\Microsoft.Windows.PowerShell.ScriptAnalyzer.dll", | ||
"$projectRoot\Rules\bin\${buildConfiguration}\${Framework}\Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.dll" | ||
"$projectRoot\Rules\bin\${buildConfiguration}\${framework}\Microsoft.PowerShell.CrossCompatibility.dll" | ||
) | ||
} | ||
Publish-File $itemsToCopyBinaries $destinationDirBinaries | ||
|
||
$settingsFiles = Get-Childitem "$projectRoot\Engine\Settings" | ForEach-Object -MemberName FullName | ||
Publish-File $settingsFiles (Join-Path -Path $script:destinationDir -ChildPath Settings) | ||
|
||
if ($framework -eq 'net452') { | ||
Copy-Item -path "$projectRoot\Rules\bin\${buildConfiguration}\${framework}\Newtonsoft.Json.dll" -Destination $destinationDirBinaries | ||
if ( $env:TF_BUILD ) { | ||
$nsoft = "$projectRoot\bin\${buildConfiguration}\${framework}\Newtonsoft.Json.dll" | ||
} | ||
else { | ||
$nsoft = "$projectRoot\Rules\bin\${buildConfiguration}\${framework}\Newtonsoft.Json.dll" | ||
} | ||
Copy-Item -path $nsoft -Destination $destinationDirBinaries | ||
} | ||
|
||
Pop-Location | ||
} | ||
} | ||
|
||
function New-Catalog | ||
{ | ||
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseCompatibleCommands', '')] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a specific diagnostic here that was appearing? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One of the stages in the sign build was to run all the tests, and one of the tests found new-filecatalog not being present in all versions, but I hadn't picked up the latest master. Also, I removed the test phase from the build since it happens in CI. I can pull this line. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nope - I need to put it back - now it's failing in the CI build There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No worries -- perhaps we can open an issue to track removing this? |
||
param ( [Parameter()]$Location ) | ||
$newFileCatalog = Get-Command -ErrorAction SilentlyContinue New-FileCatalog | ||
if ($null -eq $newFileCatalog) { | ||
Write-Warning "New-FileCatalog not found, not creating catalog" | ||
return | ||
} | ||
try { | ||
Push-Location $Location | ||
New-FileCatalog -CatalogFilePath PSScriptAnalyzer.cat -Path . | ||
} | ||
finally { | ||
Pop-Location | ||
} | ||
} | ||
|
||
# TEST HELPERS | ||
# Run our tests | ||
function Test-ScriptAnalyzer | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<SignConfigXML> | ||
<!-- ****Begin**** BothDual - Dual (Sha256 and Sha1) AuthicodeDual) and should be StrongName, but we will add this in 6.1.0 ******** --> | ||
<job platform="" configuration="" dest="__OUTPATHROOT__\signed" jobname="PowerShell Script Analyzer" approvers="vigarg;gstolt"> | ||
<file src="__INPATHROOT__\out\PSScriptAnalyzer\1.19.0\Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.dll" signType="400" dest="__OUTPATHROOT__\PSScriptAnalyzer\1.19.0\Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.dll" /> | ||
<file src="__INPATHROOT__\out\PSScriptAnalyzer\1.19.0\Microsoft.Windows.PowerShell.ScriptAnalyzer.dll" signType="400" dest="__OUTPATHROOT__\PSScriptAnalyzer\1.19.0\Microsoft.Windows.PowerShell.ScriptAnalyzer.dll" /> | ||
<file src="__INPATHROOT__\out\PSScriptAnalyzer\1.19.0\Microsoft.PowerShell.CrossCompatibility.dll" signType="400" dest="__OUTPATHROOT__\PSScriptAnalyzer\1.19.0\Microsoft.PowerShell.CrossCompatibility.dll" /> | ||
<file src="__INPATHROOT__\out\PSScriptAnalyzer\1.19.0\PSScriptAnalyzer.psd1" signType="400" dest="__OUTPATHROOT__\PSScriptAnalyzer\1.19.0\PSScriptAnalyzer.psd1" /> | ||
<file src="__INPATHROOT__\out\PSScriptAnalyzer\1.19.0\PSScriptAnalyzer.psm1" signType="400" dest="__OUTPATHROOT__\PSScriptAnalyzer\1.19.0\PSScriptAnalyzer.psm1" /> | ||
<file src="__INPATHROOT__\out\PSScriptAnalyzer\1.19.0\ScriptAnalyzer.format.ps1xml" signType="400" dest="__OUTPATHROOT__\PSScriptAnalyzer\1.19.0\ScriptAnalyzer.format.ps1xml" /> | ||
<file src="__INPATHROOT__\out\PSScriptAnalyzer\1.19.0\ScriptAnalyzer.types.ps1xml" signType="400" dest="__OUTPATHROOT__\PSScriptAnalyzer\1.19.0\ScriptAnalyzer.types.ps1xml" /> | ||
<file src="__INPATHROOT__\out\PSScriptAnalyzer\1.19.0\Settings\CmdletDesign.psd1" signType="400" dest="__OUTPATHROOT__\PSScriptAnalyzer\1.19.0\Settings\CmdletDesign.psd1" /> | ||
<file src="__INPATHROOT__\out\PSScriptAnalyzer\1.19.0\Settings\CodeFormatting.psd1" signType="400" dest="__OUTPATHROOT__\PSScriptAnalyzer\1.19.0\Settings\CodeFormatting.psd1" /> | ||
<file src="__INPATHROOT__\out\PSScriptAnalyzer\1.19.0\Settings\CodeFormattingAllman.psd1" signType="400" dest="__OUTPATHROOT__\PSScriptAnalyzer\1.19.0\Settings\CodeFormattingAllman.psd1" /> | ||
<file src="__INPATHROOT__\out\PSScriptAnalyzer\1.19.0\Settings\CodeFormattingOTBS.psd1" signType="400" dest="__OUTPATHROOT__\PSScriptAnalyzer\1.19.0\Settings\CodeFormattingOTBS.psd1" /> | ||
<file src="__INPATHROOT__\out\PSScriptAnalyzer\1.19.0\Settings\CodeFormattingStroustrup.psd1" signType="400" dest="__OUTPATHROOT__\PSScriptAnalyzer\1.19.0\Settings\CodeFormattingStroustrup.psd1" /> | ||
<file src="__INPATHROOT__\out\PSScriptAnalyzer\1.19.0\Settings\DSC.psd1" signType="400" dest="__OUTPATHROOT__\PSScriptAnalyzer\1.19.0\Settings\DSC.psd1" /> | ||
<file src="__INPATHROOT__\out\PSScriptAnalyzer\1.19.0\Settings\PSGallery.psd1" signType="400" dest="__OUTPATHROOT__\PSScriptAnalyzer\1.19.0\Settings\PSGallery.psd1" /> | ||
<file src="__INPATHROOT__\out\PSScriptAnalyzer\1.19.0\Settings\ScriptFunctions.psd1" signType="400" dest="__OUTPATHROOT__\PSScriptAnalyzer\1.19.0\Settings\ScriptFunctions.psd1" /> | ||
<file src="__INPATHROOT__\out\PSScriptAnalyzer\1.19.0\Settings\ScriptingStyle.psd1" signType="400" dest="__OUTPATHROOT__\PSScriptAnalyzer\1.19.0\Settings\ScriptingStyle.psd1" /> | ||
<file src="__INPATHROOT__\out\PSScriptAnalyzer\1.19.0\Settings\ScriptSecurity.psd1" signType="400" dest="__OUTPATHROOT__\PSScriptAnalyzer\1.19.0\Settings\ScriptSecurity.psd1" /> | ||
</job> | ||
<job platform="" configuration="" dest="__OUTPATHROOT__\signed" jobname="PowerShell Script Analyzer PSv6" approvers="vigarg;gstolt"> | ||
<file src="__INPATHROOT__\out\PSScriptAnalyzer\1.19.0\PSv6\Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.dll" signType="400" dest="__OUTPATHROOT__\PSScriptAnalyzer\1.19.0\PSv6\Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.dll" /> | ||
<file src="__INPATHROOT__\out\PSScriptAnalyzer\1.19.0\PSv6\Microsoft.Windows.PowerShell.ScriptAnalyzer.dll" signType="400" dest="__OUTPATHROOT__\PSScriptAnalyzer\1.19.0\PSv6\Microsoft.Windows.PowerShell.ScriptAnalyzer.dll" /> | ||
<file src="__INPATHROOT__\out\PSScriptAnalyzer\1.19.0\PSv6\Microsoft.PowerShell.CrossCompatibility.dll" signType="400" dest="__OUTPATHROOT__\PSScriptAnalyzer\1.19.0\PSv6\Microsoft.PowerShell.CrossCompatibility.dll" /> | ||
</job> | ||
<job platform="" configuration="" dest="__OUTPATHROOT__\signed" jobname="PowerShell Script Analyzer PSv7" approvers="vigarg;gstolt"> | ||
<file src="__INPATHROOT__\out\PSScriptAnalyzer\1.19.0\PSv7\Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.dll" signType="400" dest="__OUTPATHROOT__\PSScriptAnalyzer\1.19.0\PSv7\Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.dll" /> | ||
<file src="__INPATHROOT__\out\PSScriptAnalyzer\1.19.0\PSv7\Microsoft.Windows.PowerShell.ScriptAnalyzer.dll" signType="400" dest="__OUTPATHROOT__\PSScriptAnalyzer\1.19.0\PSv7\Microsoft.Windows.PowerShell.ScriptAnalyzer.dll" /> | ||
<file src="__INPATHROOT__\out\PSScriptAnalyzer\1.19.0\PSv7\Microsoft.PowerShell.CrossCompatibility.dll" signType="400" dest="__OUTPATHROOT__\PSScriptAnalyzer\1.19.0\PSv7\Microsoft.PowerShell.CrossCompatibility.dll" /> | ||
</job> | ||
<job platform="" configuration="" dest="__OUTPATHROOT__\signed" jobname="PowerShell Script Analyzer PSv4" approvers="vigarg;gstolt"> | ||
<file src="__INPATHROOT__\out\PSScriptAnalyzer\1.19.0\PSv4\Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.dll" signType="400" dest="__OUTPATHROOT__\PSScriptAnalyzer\1.19.0\PSv4\Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.dll" /> | ||
<file src="__INPATHROOT__\out\PSScriptAnalyzer\1.19.0\PSv4\Microsoft.Windows.PowerShell.ScriptAnalyzer.dll" signType="400" dest="__OUTPATHROOT__\PSScriptAnalyzer\1.19.0\PSv4\Microsoft.Windows.PowerShell.ScriptAnalyzer.dll" /> | ||
<file src="__INPATHROOT__\out\PSScriptAnalyzer\1.19.0\PSv4\Microsoft.PowerShell.CrossCompatibility.dll" signType="400" dest="__OUTPATHROOT__\PSScriptAnalyzer\1.19.0\PSv4\Microsoft.PowerShell.CrossCompatibility.dll" /> | ||
</job> | ||
<job platform="" configuration="" dest="__OUTPATHROOT__\signed" jobname="PowerShell Script Analyzer PSv3" approvers="vigarg;gstolt"> | ||
<file src="__INPATHROOT__\out\PSScriptAnalyzer\1.19.0\PSv3\Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.dll" signType="400" dest="__OUTPATHROOT__\PSScriptAnalyzer\1.19.0\PSv3\Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.dll" /> | ||
<file src="__INPATHROOT__\out\PSScriptAnalyzer\1.19.0\PSv3\Microsoft.Windows.PowerShell.ScriptAnalyzer.dll" signType="400" dest="__OUTPATHROOT__\PSScriptAnalyzer\1.19.0\PSv3\Microsoft.Windows.PowerShell.ScriptAnalyzer.dll" /> | ||
<file src="__INPATHROOT__\out\PSScriptAnalyzer\1.19.0\PSv3\Microsoft.PowerShell.CrossCompatibility.dll" signType="400" dest="__OUTPATHROOT__\PSScriptAnalyzer\1.19.0\PSv3\Microsoft.PowerShell.CrossCompatibility.dll" /> | ||
</job> | ||
</SignConfigXML> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<SignConfigXML> | ||
<job platform="" configuration="" dest="__OUTPATHROOT__\signed" jobname="PowerShell Script Analyzer File Catalog" approvers="vigarg;gstolt"> | ||
<file src="__INPATHROOT__\PSScriptAnalyzer\1.19.0\PSScriptAnalyzer.cat" signType="400" dest="__OUTPATHROOT__\PSScriptAnalyzer\1.19.0\PSScriptAnalyzer.cat" /> | ||
</job> | ||
</SignConfigXML> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"tool": "Credential Scanner", | ||
"suppressions": [ | ||
{ "file": "\\Engine\\Settings\\desktop-4.0-windows.json", | ||
"_justification": "The file contains the list of all parameters of a cmdlet but no passwords are actually present." }, | ||
{ "file": "\\Engine\\Settings\\desktop-3.0-windows.json", | ||
"_justification": "The file contains the list of all parameters of a cmdlet but no passwords are actually present." }, | ||
{ "file": "\\Engine\\Settings\\desktop-5.1.14393.206-windows.json", | ||
"_justification": "The file contains the list of all parameters of a cmdlet but no passwords are actually present." }, | ||
{ "file": "\\Tests\\Engine\\RuleSuppression.tests.ps1", | ||
"_justification": "The parameter password is used in function declaration for test but is not called and no password is present." } | ||
] | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed? PowerShell has the $VerbosePreference variable for that and should automatically propagate the usage of
-Verbose
to down to the other called cmdlets (splatting is the only exception where this does not work as far as I am aware)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because I want finer grained control, I don't want verbose everywhere. I tried it without and the logs are super large and I would rather be more targeted (no reason to be verbose on import-module for example).