diff --git a/Tests/Rules/UseCompatibleCommands.Tests.ps1 b/Tests/Rules/UseCompatibleCommands.Tests.ps1
index 2e38ba7e3..e2ac6ca68 100644
--- a/Tests/Rules/UseCompatibleCommands.Tests.ps1
+++ b/Tests/Rules/UseCompatibleCommands.Tests.ps1
@@ -400,7 +400,7 @@ Describe 'UseCompatibleCommands' {
}
$diagnostics = Invoke-ScriptAnalyzer -Path "$PSScriptRoot/../../" -IncludeRule $script:RuleName -Settings $settings
- $diagnostics.Count | Should -Be 0 -Because ($diagnostics.RuleName -join ', ')
+ $diagnostics.Count | Should -Be 0 -Because ($diagnostics.Message -join ', ')
}
}
diff --git a/build.ps1 b/build.ps1
index 94f3cbf4e..3cf8cad8e 100644
--- a/build.ps1
+++ b/build.ps1
@@ -34,13 +34,24 @@ param(
[switch] $InProcess,
[Parameter(ParameterSetName='Bootstrap')]
- [switch] $Bootstrap
+ [switch] $Bootstrap,
+
+ [Parameter(ParameterSetName='BuildAll')]
+ [switch] $Catalog
+
)
+BEGIN {
+ $verboseWanted = $false
+ if ( $PSBoundParameters['Verbose'] ) {
+ $verboseWanted = $PSBoundParameters['Verbose'].ToBool()
+ }
+}
+
END {
- Import-Module -Force (Join-Path $PSScriptRoot build.psm1)
+ Import-Module -Force (Join-Path $PSScriptRoot build.psm1) -verbose:$false
if ( $Clean -or $Clobber ) {
- Remove-Build
+ Remove-Build -verbose:$false
if ( $PSCmdlet.ParameterSetName -eq "Clean" ) {
return
}
@@ -49,10 +60,19 @@ END {
$setName = $PSCmdlet.ParameterSetName
switch ( $setName ) {
"BuildAll" {
- Start-ScriptAnalyzerBuild -All -Configuration $Configuration
+ $buildArgs = @{
+ All = $true
+ Configuration = $Configuration
+ Verbose = $verboseWanted
+ Catalog = $false
+ }
+ if ( $Catalog ) {
+ $buildArgs['Catalog'] = $true
+ }
+ Start-ScriptAnalyzerBuild @buildArgs
}
"BuildDocumentation" {
- Start-ScriptAnalyzerBuild -Documentation
+ Start-ScriptAnalyzerBuild -Documentation -Verbose:$Verbose
}
"BuildOne" {
$buildArgs = @{
diff --git a/build.psm1 b/build.psm1
index 827654bc2..17b584c3c 100644
--- a/build.psm1
+++ b/build.psm1
@@ -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,6 +165,10 @@ 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 {
@@ -170,20 +176,25 @@ function Start-ScriptAnalyzerBuild
$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', '')]
+ 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
diff --git a/tools/releaseBuild/AssemblySignConfig.xml b/tools/releaseBuild/AssemblySignConfig.xml
new file mode 100644
index 000000000..2d2738804
--- /dev/null
+++ b/tools/releaseBuild/AssemblySignConfig.xml
@@ -0,0 +1,43 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tools/releaseBuild/CatalogSignConfig.xml b/tools/releaseBuild/CatalogSignConfig.xml
new file mode 100644
index 000000000..73091961b
--- /dev/null
+++ b/tools/releaseBuild/CatalogSignConfig.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/tools/releaseBuild/CredScan.Suppressions.json b/tools/releaseBuild/CredScan.Suppressions.json
new file mode 100644
index 000000000..53b49888f
--- /dev/null
+++ b/tools/releaseBuild/CredScan.Suppressions.json
@@ -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." }
+ ]
+}
+
+