Skip to content

Commit 66ab86f

Browse files
committed
Check PS Version when importing Az.Storage which using Azure.Core
1 parent ca6797e commit 66ab86f

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

tools/AzureRM.Example.psm1

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ if (%ISAZMODULE% -and ($PSEdition -eq 'Desktop'))
3434
Test-DotNet
3535
}
3636

37+
%AZURECOREPREREQUISITE%
38+
3739
if (Test-Path -Path "$PSScriptRoot\StartupScripts" -ErrorAction Ignore)
3840
{
3941
Get-ChildItem "$PSScriptRoot\StartupScripts" -ErrorAction Stop | ForEach-Object {
@@ -60,7 +62,7 @@ if($PSEdition -eq 'Desktop' -and (Test-Path $preloadPath -ErrorAction Ignore))
6062
Add-Type -Path $_.FullName -ErrorAction Ignore | Out-Null
6163
}
6264
catch {
63-
Write-Warning $_
65+
Write-Verbose $_
6466
}
6567
}
6668
}
@@ -83,7 +85,7 @@ if($PSEdition -eq 'Core' -and (Test-Path $netCorePath -ErrorAction Ignore))
8385
Add-Type -Path $_.FullName -ErrorAction Ignore | Out-Null
8486
}
8587
catch {
86-
Write-Warning $_
88+
Write-Verbose $_
8789
}
8890
}
8991
}

tools/UpdateModules.ps1

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,24 @@ function New-ModulePsm1 {
9595
$template = $template -replace "%DATE%", [string](Get-Date)
9696
$template = $template -replace "%IMPORTED-DEPENDENCIES%", $importedModules
9797

98+
#Az.Storage is using Azure.Core, so need to check PS version
99+
if ($IsNetcore -and $file.BaseName -eq 'Az.Storage')
100+
{
101+
$template = $template -replace "%AZURECOREPREREQUISITE%",
102+
@"
103+
if (%ISAZMODULE% -and (`$PSEdition -eq 'Core'))
104+
{
105+
if (`$PSVersionTable.PSVersion -lt [Version]'6.2.4')
106+
{
107+
throw "Az.Storage doesn't support PowerShell Core versions lower than 6.2.4. Please upgrade to PowerShell Core 6.2.4 or higher."
108+
}
109+
}
110+
"@
111+
}
112+
else
113+
{
114+
$template = $template -replace "%AZURECOREPREREQUISITE%", ""
115+
}
98116
# Replace Az or AzureRM with correct information
99117
if ($IsNetcore)
100118
{

0 commit comments

Comments
 (0)