Skip to content

Check PowerShell Core version when importing Az.Storage #11576

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

Merged
merged 5 commits into from
Apr 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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