1
1
# Copyright (c) Microsoft Corporation. All rights reserved.
2
2
# Licensed under the MIT License.
3
3
4
+ Set-StrictMode - Version 3.0
5
+
4
6
# On Unix paths is separated by colon
5
7
# On Windows paths is separated by semicolon
6
8
$script :TestModulePathSeparator = [System.IO.Path ]::PathSeparator
9
+ $script :Options = $null
7
10
8
11
$dotnetCLIChannel = ' release'
9
12
$dotnetCLIRequiredVersion = $ (Get-Content $PSScriptRoot / global.json | ConvertFrom-Json ).Sdk.Version
@@ -292,7 +295,7 @@ function Start-PSBuild {
292
295
$PSModuleRestore = $true
293
296
}
294
297
295
- if ($Runtime -eq " linux-arm" -and -not $environment.IsUbuntu ) {
298
+ if ($Runtime -eq " linux-arm" -and $environment .IsLinux -and -not $environment.IsUbuntu ) {
296
299
throw " Cross compiling for linux-arm is only supported on Ubuntu environment"
297
300
}
298
301
@@ -499,32 +502,34 @@ Fix steps:
499
502
$psVersion = git -- git- dir= " $PSScriptRoot /.git" describe
500
503
}
501
504
502
- if ($environment.IsRedHatFamily -or $environment.IsDebian ) {
503
- # Symbolic links added here do NOT affect packaging as we do not build on Debian.
504
- # add two symbolic links to system shared libraries that libmi.so is dependent on to handle
505
- # platform specific changes. This is the only set of platforms needed for this currently
506
- # as Ubuntu has these specific library files in the platform and macOS builds for itself
507
- # against the correct versions.
508
-
509
- if ($environment.IsDebian10 -or $environment.IsDebian11 ){
510
- $sslTarget = " /usr/lib/x86_64-linux-gnu/libssl.so.1.1"
511
- $cryptoTarget = " /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1"
512
- }
513
- elseif ($environment.IsDebian9 ){
514
- # NOTE: Debian 8 doesn't need these symlinks
515
- $sslTarget = " /usr/lib/x86_64-linux-gnu/libssl.so.1.0.2"
516
- $cryptoTarget = " /usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.2"
517
- }
518
- else { # IsRedHatFamily
519
- $sslTarget = " /lib64/libssl.so.10"
520
- $cryptoTarget = " /lib64/libcrypto.so.10"
521
- }
505
+ if ($environment.IsLinux ) {
506
+ if ($environment.IsRedHatFamily -or $environment.IsDebian ) {
507
+ # Symbolic links added here do NOT affect packaging as we do not build on Debian.
508
+ # add two symbolic links to system shared libraries that libmi.so is dependent on to handle
509
+ # platform specific changes. This is the only set of platforms needed for this currently
510
+ # as Ubuntu has these specific library files in the platform and macOS builds for itself
511
+ # against the correct versions.
512
+
513
+ if ($environment.IsDebian10 -or $environment.IsDebian11 ){
514
+ $sslTarget = " /usr/lib/x86_64-linux-gnu/libssl.so.1.1"
515
+ $cryptoTarget = " /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1"
516
+ }
517
+ elseif ($environment.IsDebian9 ){
518
+ # NOTE: Debian 8 doesn't need these symlinks
519
+ $sslTarget = " /usr/lib/x86_64-linux-gnu/libssl.so.1.0.2"
520
+ $cryptoTarget = " /usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.2"
521
+ }
522
+ else { # IsRedHatFamily
523
+ $sslTarget = " /lib64/libssl.so.10"
524
+ $cryptoTarget = " /lib64/libcrypto.so.10"
525
+ }
522
526
523
- if ( ! (test-path " $publishPath /libssl.so.1.0.0" )) {
524
- $null = New-Item - Force - ItemType SymbolicLink - Target $sslTarget - Path " $publishPath /libssl.so.1.0.0" - ErrorAction Stop
525
- }
526
- if ( ! (test-path " $publishPath /libcrypto.so.1.0.0" )) {
527
- $null = New-Item - Force - ItemType SymbolicLink - Target $cryptoTarget - Path " $publishPath /libcrypto.so.1.0.0" - ErrorAction Stop
527
+ if ( ! (test-path " $publishPath /libssl.so.1.0.0" )) {
528
+ $null = New-Item - Force - ItemType SymbolicLink - Target $sslTarget - Path " $publishPath /libssl.so.1.0.0" - ErrorAction Stop
529
+ }
530
+ if ( ! (test-path " $publishPath /libcrypto.so.1.0.0" )) {
531
+ $null = New-Item - Force - ItemType SymbolicLink - Target $cryptoTarget - Path " $publishPath /libcrypto.so.1.0.0" - ErrorAction Stop
532
+ }
528
533
}
529
534
}
530
535
@@ -579,6 +584,7 @@ Fix steps:
579
584
580
585
function Restore-PSPackage
581
586
{
587
+ [CmdletBinding ()]
582
588
param (
583
589
[ValidateNotNullOrEmpty ()]
584
590
[Parameter ()]
@@ -618,7 +624,7 @@ function Restore-PSPackage
618
624
$RestoreArguments = @ (" /property:SDKToUse=$sdkToUse " , " --verbosity" )
619
625
}
620
626
621
- if ($PSCmdlet .MyInvocation.BoundParameters [ " Verbose " ].IsPresent ) {
627
+ if ($VerbosePreference -eq ' Continue ' ) {
622
628
$RestoreArguments += " detailed"
623
629
} else {
624
630
$RestoreArguments += " quiet"
@@ -837,7 +843,7 @@ function Get-PSOptions {
837
843
$DefaultToNew
838
844
)
839
845
840
- if (! $script :Options -and $DefaultToNew.IsPresent )
846
+ if (! $script :Options -and $DefaultToNew.IsPresent )
841
847
{
842
848
return New-PSOptions
843
849
}
@@ -876,7 +882,14 @@ function Get-PesterTag {
876
882
$fullname = $_.fullname
877
883
$tok = $err = $null
878
884
$ast = [System.Management.Automation.Language.Parser ]::ParseFile($FullName , [ref ]$tok , [ref ]$err )
879
- $des = $ast.FindAll ({$args [0 ] -is " System.Management.Automation.Language.CommandAst" -and $args [0 ].CommandElements[0 ].Value -eq " Describe" }, $true )
885
+ $des = $ast.FindAll ({
886
+ $args [0 ] -is [System.Management.Automation.Language.CommandAst ] `
887
+ -and $args [0 ].CommandElements.GetType() -in @ (
888
+ [System.Management.Automation.Language.StringConstantExpressionAst ],
889
+ [System.Management.Automation.Language.ExpandableStringExpressionAst ]
890
+ ) `
891
+ -and $args [0 ].CommandElements[0 ].Value -eq " Describe"
892
+ }, $true )
880
893
foreach ( $describe in $des ) {
881
894
$elements = $describe.CommandElements
882
895
$lineno = $elements [0 ].Extent.StartLineNumber
@@ -1079,7 +1092,7 @@ function Start-PSPester {
1079
1092
$publishArgs = @ { }
1080
1093
# if we are building for Alpine, we must include the runtime as linux-x64
1081
1094
# will not build runnable test tools
1082
- if ( $environment.IsAlpine ) {
1095
+ if ( $environment.IsLinux -and $environment . IsAlpine ) {
1083
1096
$publishArgs [' runtime' ] = ' alpine-x64'
1084
1097
}
1085
1098
Publish-PSTestTools @publishArgs | ForEach-Object {Write-Host $_ }
@@ -1615,7 +1628,7 @@ function Install-Dotnet {
1615
1628
$curl = Get-Command - Name curl - CommandType Application - TotalCount 1 - ErrorAction Stop
1616
1629
1617
1630
# Uninstall all previous dotnet packages
1618
- $uninstallScript = if ($environment.IsUbuntu ) {
1631
+ $uninstallScript = if ($environment.IsLinux -and $environment . IsUbuntu ) {
1619
1632
" dotnet-uninstall-debian-packages.sh"
1620
1633
} elseif ($environment.IsMacOS ) {
1621
1634
" dotnet-uninstall-pkgs.sh"
@@ -1687,14 +1700,14 @@ function Start-PSBootstrap {
1687
1700
# Note that when it is null, Invoke-Expression (but not &) must be used to interpolate properly
1688
1701
$sudo = if (! $NoSudo ) { " sudo" }
1689
1702
1690
- if ($BuildLinuxArm -and -not $environment.IsUbuntu ) {
1703
+ if ($BuildLinuxArm -and $environment .IsLinux -and -not $environment.IsUbuntu ) {
1691
1704
Write-Error " Cross compiling for linux-arm is only supported on Ubuntu environment"
1692
1705
return
1693
1706
}
1694
1707
1695
1708
# Install ours and .NET's dependencies
1696
1709
$Deps = @ ()
1697
- if ($environment.IsUbuntu ) {
1710
+ if ($environment.IsLinux -and $environment . IsUbuntu ) {
1698
1711
# Build tools
1699
1712
$Deps += " curl" , " g++" , " cmake" , " make"
1700
1713
@@ -1724,7 +1737,7 @@ function Start-PSBootstrap {
1724
1737
# change the apt frontend back to the original
1725
1738
$env: DEBIAN_FRONTEND = $originalDebianFrontEnd
1726
1739
}
1727
- } elseif ($environment.IsRedHatFamily ) {
1740
+ } elseif ($environment.IsLinux -and $environment . IsRedHatFamily ) {
1728
1741
# Build tools
1729
1742
$Deps += " which" , " curl" , " gcc-c++" , " cmake" , " make"
1730
1743
@@ -1748,7 +1761,7 @@ function Start-PSBootstrap {
1748
1761
Start-NativeExecution {
1749
1762
Invoke-Expression " $baseCommand $Deps "
1750
1763
}
1751
- } elseif ($environment.IsSUSEFamily ) {
1764
+ } elseif ($environment.IsLinux -and $environment . IsSUSEFamily ) {
1752
1765
# Build tools
1753
1766
$Deps += " gcc" , " cmake" , " make"
1754
1767
@@ -1784,7 +1797,7 @@ function Start-PSBootstrap {
1784
1797
# Install dependencies
1785
1798
# ignore exitcode, because they may be already installed
1786
1799
Start-NativeExecution ([ScriptBlock ]::Create(" $PackageManager install $Deps " )) - IgnoreExitcode
1787
- } elseif ($environment.IsAlpine ) {
1800
+ } elseif ($environment.IsLinux -and $environment . IsAlpine ) {
1788
1801
$Deps += ' libunwind' , ' libcurl' , ' bash' , ' cmake' , ' clang' , ' build-base' , ' git' , ' curl'
1789
1802
1790
1803
Start-NativeExecution {
@@ -2105,8 +2118,8 @@ function script:Start-NativeExecution
2105
2118
[switch ]$IgnoreExitcode ,
2106
2119
[switch ]$VerboseOutputOnError
2107
2120
)
2108
- $backupEAP = $script : ErrorActionPreference
2109
- $script : ErrorActionPreference = " Continue"
2121
+ $backupEAP = $ErrorActionPreference
2122
+ $ErrorActionPreference = " Continue"
2110
2123
try {
2111
2124
if ($VerboseOutputOnError.IsPresent )
2112
2125
{
@@ -2139,7 +2152,7 @@ function script:Start-NativeExecution
2139
2152
throw " Execution of {$sb } failed with exit code $LASTEXITCODE "
2140
2153
}
2141
2154
} finally {
2142
- $script : ErrorActionPreference = $backupEAP
2155
+ $ErrorActionPreference = $backupEAP
2143
2156
}
2144
2157
}
2145
2158
0 commit comments