diff --git a/Tasks/AzureCloudPowerShellDeployment/task.json b/Tasks/AzureCloudPowerShellDeployment/task.json index 5bf541e421f2..61f5c60e16ee 100644 --- a/Tasks/AzureCloudPowerShellDeployment/task.json +++ b/Tasks/AzureCloudPowerShellDeployment/task.json @@ -16,7 +16,7 @@ "version": { "Major": 1, "Minor": 2, - "Patch": 0 + "Patch": 1 }, "demands": [ "azureps" diff --git a/Tasks/AzureCloudPowerShellDeployment/task.loc.json b/Tasks/AzureCloudPowerShellDeployment/task.loc.json index 64e6cc3a2013..c80171004c69 100644 --- a/Tasks/AzureCloudPowerShellDeployment/task.loc.json +++ b/Tasks/AzureCloudPowerShellDeployment/task.loc.json @@ -16,7 +16,7 @@ "version": { "Major": 1, "Minor": 2, - "Patch": 0 + "Patch": 1 }, "demands": [ "azureps" diff --git a/Tasks/AzureFileCopy/task.json b/Tasks/AzureFileCopy/task.json index 5b96d201828c..93303c05ac1b 100644 --- a/Tasks/AzureFileCopy/task.json +++ b/Tasks/AzureFileCopy/task.json @@ -13,7 +13,7 @@ "version": { "Major": 1, "Minor": 0, - "Patch": 109 + "Patch": 110 }, "demands": [ "azureps" diff --git a/Tasks/AzureFileCopy/task.loc.json b/Tasks/AzureFileCopy/task.loc.json index a59958916106..b6c8215bea37 100644 --- a/Tasks/AzureFileCopy/task.loc.json +++ b/Tasks/AzureFileCopy/task.loc.json @@ -13,7 +13,7 @@ "version": { "Major": 1, "Minor": 0, - "Patch": 109 + "Patch": 110 }, "demands": [ "azureps" diff --git a/Tasks/AzurePowerShell/task.json b/Tasks/AzurePowerShell/task.json index 66aff5753e94..a2fca682536f 100644 --- a/Tasks/AzurePowerShell/task.json +++ b/Tasks/AzurePowerShell/task.json @@ -17,7 +17,7 @@ "version": { "Major": 3, "Minor": 0, - "Patch": 0 + "Patch": 1 }, "releaseNotes": "This is an early preview. Added support for Fail on standard error and ErrorActionPreference", "demands": [ diff --git a/Tasks/AzurePowerShell/task.loc.json b/Tasks/AzurePowerShell/task.loc.json index 12db0be5558d..1a35cd0e1963 100644 --- a/Tasks/AzurePowerShell/task.loc.json +++ b/Tasks/AzurePowerShell/task.loc.json @@ -17,7 +17,7 @@ "version": { "Major": 3, "Minor": 0, - "Patch": 0 + "Patch": 1 }, "releaseNotes": "ms-resource:loc.releaseNotes", "demands": [ diff --git a/Tasks/Common/VstsAzureHelpers_/ImportFunctions.ps1 b/Tasks/Common/VstsAzureHelpers_/ImportFunctions.ps1 index fef1ae8f297a..9f72d2dd9439 100644 --- a/Tasks/Common/VstsAzureHelpers_/ImportFunctions.ps1 +++ b/Tasks/Common/VstsAzureHelpers_/ImportFunctions.ps1 @@ -108,14 +108,25 @@ function Import-FromModulePath { } else { # The AzureRM module was imported. # Validate the AzureRM.profile module can be found. - $profileModule = (Get-Module -Name AzureRM).NestedModules | Where-Object { $_.Name.toLower() -eq "azurerm.profile" } - if (!$profileModule) { - throw (Get-VstsLocString -Key AZ_AzureRMProfileModuleNotFound) + # First check whether or not profile module is already loaded in the current session + $profileModule = Get-Module -Name AzureRm.Profile + if(!$profileModule) { + # otherwise check whether it is listed as a nested module in the azurerm module manifest ( this is valid till v 5.3.0 ) + $profileModule = (Get-Module -Name AzureRM).NestedModules | Where-Object { $_.Name.toLower() -eq "azurerm.profile" } + # otherwise check whether it is listed as a required module in the azurerm module manifest ( valid from v 5.4.0 and up ) + if(!$profileModule) { + $profileModule = (Get-Module -Name AzureRM).RequiredModules | Where-Object { $_.Name.toLower() -eq "azurerm.profile" } + } + if (!$profileModule) { + throw (Get-VstsLocString -Key AZ_AzureRMProfileModuleNotFound) + } + # Import and then store the AzureRM.profile module. + Write-Host "##[command]Import-Module -Name $($profileModule.Path) -Global" + $script:azureRMProfileModule = Import-Module -Name $profileModule.Path -Global -PassThru + } else { + $script:azureRMProfileModule = $profileModule } - # Import and then store the AzureRM.profile module. - Write-Host "##[command]Import-Module -Name $($profileModule.Path) -Global" - $script:azureRMProfileModule = Import-Module -Name $profileModule.Path -Global -PassThru - Write-Verbose "Imported module version: $($script:azureRMProfileModule.Version)" + Write-Verbose "Imported module version: $($script:azureRMProfileModule.Version)" } return $true diff --git a/Tasks/Common/VstsAzureHelpers_/Tests/Import-FromModulePath.ValidatesRMProfileFound.ps1 b/Tasks/Common/VstsAzureHelpers_/Tests/Import-FromModulePath.ValidatesRMProfileFound.ps1 index 41674f134e55..de4664585c0c 100644 --- a/Tasks/Common/VstsAzureHelpers_/Tests/Import-FromModulePath.ValidatesRMProfileFound.ps1 +++ b/Tasks/Common/VstsAzureHelpers_/Tests/Import-FromModulePath.ValidatesRMProfileFound.ps1 @@ -14,7 +14,8 @@ $rmModule = @{ Name = 'AzureRM' ; @{ Name = "AzureRM.Compute" } - ) + ); + RequiredModules = @() } Register-Mock Get-Module { $rmModule } -- -Name $rmModule.Name -ListAvailable Register-Mock Get-Module { $rmModule } -- -Name $rmModule.Name