Skip to content

Commit

Permalink
Check PS Version when importing Az.Storage which using Azure.Core (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
erich-wang authored Apr 15, 2020
1 parent 30a1010 commit e6a9980
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tools/AzureRM.Example.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ if (%ISAZMODULE% -and ($PSEdition -eq 'Desktop'))
Test-DotNet
}

%AZURECOREPREREQUISITE%

if (Test-Path -Path "$PSScriptRoot\StartupScripts" -ErrorAction Ignore)
{
Get-ChildItem "$PSScriptRoot\StartupScripts" -ErrorAction Stop | ForEach-Object {
Expand All @@ -60,7 +62,7 @@ if($PSEdition -eq 'Desktop' -and (Test-Path $preloadPath -ErrorAction Ignore))
Add-Type -Path $_.FullName -ErrorAction Ignore | Out-Null
}
catch {
Write-Warning $_
Write-Verbose $_
}
}
}
Expand All @@ -83,7 +85,7 @@ if($PSEdition -eq 'Core' -and (Test-Path $netCorePath -ErrorAction Ignore))
Add-Type -Path $_.FullName -ErrorAction Ignore | Out-Null
}
catch {
Write-Warning $_
Write-Verbose $_
}
}
}
Expand Down
18 changes: 18 additions & 0 deletions tools/UpdateModules.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,24 @@ function New-ModulePsm1 {
$template = $template -replace "%DATE%", [string](Get-Date)
$template = $template -replace "%IMPORTED-DEPENDENCIES%", $importedModules

#Az.Storage is using Azure.Core, so need to check PS version
if ($IsNetcore -and $file.BaseName -eq 'Az.Storage')
{
$template = $template -replace "%AZURECOREPREREQUISITE%",
@"
if (%ISAZMODULE% -and (`$PSEdition -eq 'Core'))
{
if (`$PSVersionTable.PSVersion -lt [Version]'6.2.4')
{
throw "Az.Storage doesn't support PowerShell Core versions lower than 6.2.4. Please upgrade to PowerShell Core 6.2.4 or higher."
}
}
"@
}
else
{
$template = $template -replace "%AZURECOREPREREQUISITE%", ""
}
# Replace Az or AzureRM with correct information
if ($IsNetcore)
{
Expand Down

0 comments on commit e6a9980

Please sign in to comment.