Skip to content

Commit fab51a9

Browse files
authored
Fixing bug (#11295)
1 parent 57937ef commit fab51a9

File tree

4 files changed

+24
-40
lines changed

4 files changed

+24
-40
lines changed

Tasks/AzurePowerShellV4/AzurePowerShell.ps1

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,28 @@ if ($targetAzurePs -eq $latestVersion) {
4848

4949
$serviceName = Get-VstsInput -Name ConnectedServiceNameARM -Require
5050
$endpoint = Get-VstsEndpoint -Name $serviceName -Require
51-
$env:PSModulePath = Get-VstsTaskVariable -Name "AZ_PS_MODULE_PATH"
51+
52+
$azureRMModulePath = "C:\Modules\azurerm_2.1.0"
53+
$azureModulePath = "C:\Modules\azure_2.1.0"
54+
$azPSModulePath = $env:PSModulePath
55+
56+
if ($azPSModulePath.split(";") -contains $azureRMModulePath) {
57+
$azPSModulePath = (($azPSModulePath).Split(";") | ? { $_ -ne $azureRMModulePath }) -join ";"
58+
write-verbose "$azureRMModulePath removed. Restart the prompt for the changes to take effect."
59+
}
60+
else {
61+
write-verbose "$azureRMModulePath is not present in $azPSModulePath"
62+
}
63+
64+
if ($azPSModulePath.split(";") -contains $azureModulePath) {
65+
$azPSModulePath = (($azPSModulePath).Split(";") | ? { $_ -ne $azureModulePath }) -join ";"
66+
write-verbose "$azureModulePath removed. Restart the prompt for the changes to take effect."
67+
}
68+
else {
69+
write-verbose "$azureModulePath is not present in $azPSModulePath"
70+
}
71+
72+
$env:PSModulePath = $azPSModulePath
5273

5374
Update-PSModulePathForHostedAgent -targetAzurePs $targetAzurePs
5475

Tasks/AzurePowerShellV4/PreJobExecutionAzurePowerShell.ps1

Lines changed: 0 additions & 21 deletions
This file was deleted.

Tasks/AzurePowerShellV4/task.json

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"version": {
1818
"Major": 4,
1919
"Minor": 157,
20-
"Patch": 3
20+
"Patch": 4
2121
},
2222
"preview": true,
2323
"releaseNotes": "Added support for Az Module and cross platform agents.",
@@ -143,14 +143,6 @@
143143
}
144144
],
145145
"instanceNameFormat": "Azure PowerShell script: $(ScriptType)",
146-
"prejobexecution": {
147-
"PowerShell3": {
148-
"target": "PreJobExecutionAzurePowerShell.ps1",
149-
"platforms": [
150-
"windows"
151-
]
152-
}
153-
},
154146
"execution": {
155147
"PowerShell3": {
156148
"target": "azurepowershell.ps1",

Tasks/AzurePowerShellV4/task.loc.json

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"version": {
1818
"Major": 4,
1919
"Minor": 157,
20-
"Patch": 3
20+
"Patch": 4
2121
},
2222
"preview": true,
2323
"releaseNotes": "ms-resource:loc.releaseNotes",
@@ -143,14 +143,6 @@
143143
}
144144
],
145145
"instanceNameFormat": "ms-resource:loc.instanceNameFormat",
146-
"prejobexecution": {
147-
"PowerShell3": {
148-
"target": "PreJobExecutionAzurePowerShell.ps1",
149-
"platforms": [
150-
"windows"
151-
]
152-
}
153-
},
154146
"execution": {
155147
"PowerShell3": {
156148
"target": "azurepowershell.ps1",

0 commit comments

Comments
 (0)