Skip to content

Fixed AzureRm and Az module warning #19982

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 2 commits into from
Jun 11, 2024
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
37 changes: 19 additions & 18 deletions Tasks/AzureFileCopyV4/Utility.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1347,27 +1347,28 @@ function Get-InvokeRemoteScriptParameters
}

function CleanUp-PSModulePathForHostedAgent {

# Define the module paths to clean up
$modulePaths = @(
"C:\Modules\azurerm_2.1.0",
"C:\\Modules\azurerm_2.1.0",
"C:\Modules\azure_2.1.0",
"C:\\Modules\azure_2.1.0"
)

# Clean up PSModulePath for hosted agent
$azureRMModulePath = "C:\Modules\azurerm_2.1.0"
$azureModulePath = "C:\Modules\azure_2.1.0"
$newEnvPSModulePath = $env:PSModulePath

if ($newEnvPSModulePath.split(";") -contains $azureRMModulePath) {
$newEnvPSModulePath = (($newEnvPSModulePath).Split(";") | ? { $_ -ne $azureRMModulePath }) -join ";"
write-verbose "$azureRMModulePath removed. Restart the prompt for the changes to take effect."
}
else {
write-verbose "$azureRMModulePath is not present in $newEnvPSModulePath"
}

if ($newEnvPSModulePath.split(";") -contains $azureModulePath) {
$newEnvPSModulePath = (($newEnvPSModulePath).Split(";") | ? { $_ -ne $azureModulePath }) -join ";"
write-verbose "$azureModulePath removed. Restart the prompt for the changes to take effect."
}
else {
write-verbose "$azureModulePath is not present in $newEnvPSModulePath"

foreach ($modulePath in $modulePaths) {
if ($newEnvPSModulePath.split(";") -contains $modulePath) {
$newEnvPSModulePath = (($newEnvPSModulePath).Split(";") | ? { $_ -ne $modulePath }) -join ";"
Write-Verbose "$modulePath removed. Restart the prompt for the changes to take effect."
}
else {
Write-Verbose "$modulePath is not present in $newEnvPSModulePath"
}
}

if (Test-Path "C:\Modules\az_*") {
$azPSModulePath = (Get-ChildItem "C:\Modules\az_*" -Directory `
| Sort-Object { [version]$_.Name.Split('_')[-1] } `
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureFileCopyV4/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"version": {
"Major": 4,
"Minor": 241,
"Patch": 0
"Patch": 2
},
"demands": [
"azureps"
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureFileCopyV4/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"version": {
"Major": 4,
"Minor": 241,
"Patch": 0
"Patch": 2
},
"demands": [
"azureps"
Expand Down
37 changes: 19 additions & 18 deletions Tasks/AzureFileCopyV5/Utility.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1361,27 +1361,28 @@ function Get-InvokeRemoteScriptParameters
}

function CleanUp-PSModulePathForHostedAgent {

# Define the module paths to clean up
$modulePaths = @(
"C:\Modules\azurerm_2.1.0",
"C:\\Modules\azurerm_2.1.0",
"C:\Modules\azure_2.1.0",
"C:\\Modules\azure_2.1.0"
)

# Clean up PSModulePath for hosted agent
$azureRMModulePath = "C:\Modules\azurerm_2.1.0"
$azureModulePath = "C:\Modules\azure_2.1.0"
$newEnvPSModulePath = $env:PSModulePath

if ($newEnvPSModulePath.split(";") -contains $azureRMModulePath) {
$newEnvPSModulePath = (($newEnvPSModulePath).Split(";") | ? { $_ -ne $azureRMModulePath }) -join ";"
write-verbose "$azureRMModulePath removed. Restart the prompt for the changes to take effect."
}
else {
write-verbose "$azureRMModulePath is not present in $newEnvPSModulePath"
}

if ($newEnvPSModulePath.split(";") -contains $azureModulePath) {
$newEnvPSModulePath = (($newEnvPSModulePath).Split(";") | ? { $_ -ne $azureModulePath }) -join ";"
write-verbose "$azureModulePath removed. Restart the prompt for the changes to take effect."
}
else {
write-verbose "$azureModulePath is not present in $newEnvPSModulePath"

foreach ($modulePath in $modulePaths) {
if ($newEnvPSModulePath.split(";") -contains $modulePath) {
$newEnvPSModulePath = (($newEnvPSModulePath).Split(";") | ? { $_ -ne $modulePath }) -join ";"
Write-Verbose "$modulePath removed. Restart the prompt for the changes to take effect."
}
else {
Write-Verbose "$modulePath is not present in $newEnvPSModulePath"
}
}

if (Test-Path "C:\Modules\az_*") {
$azPSModulePath = (Get-ChildItem "C:\Modules\az_*" -Directory `
| Sort-Object { [version]$_.Name.Split('_')[-1] } `
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureFileCopyV5/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"version": {
"Major": 5,
"Minor": 241,
"Patch": 0
"Patch": 2
},
"demands": [
"azureps"
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureFileCopyV5/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"version": {
"Major": 5,
"Minor": 241,
"Patch": 0
"Patch": 2
},
"demands": [
"azureps"
Expand Down
37 changes: 19 additions & 18 deletions Tasks/AzureFileCopyV6/Utility.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1348,27 +1348,28 @@ function Get-InvokeRemoteScriptParameters
}

function CleanUp-PSModulePathForHostedAgent {

# Define the module paths to clean up
$modulePaths = @(
"C:\Modules\azurerm_2.1.0",
"C:\\Modules\azurerm_2.1.0",
"C:\Modules\azure_2.1.0",
"C:\\Modules\azure_2.1.0"
)

# Clean up PSModulePath for hosted agent
$azureRMModulePath = "C:\Modules\azurerm_2.1.0"
$azureModulePath = "C:\Modules\azure_2.1.0"
$newEnvPSModulePath = $env:PSModulePath

if ($newEnvPSModulePath.split(";") -contains $azureRMModulePath) {
$newEnvPSModulePath = (($newEnvPSModulePath).Split(";") | ? { $_ -ne $azureRMModulePath }) -join ";"
write-verbose "$azureRMModulePath removed. Restart the prompt for the changes to take effect."
}
else {
write-verbose "$azureRMModulePath is not present in $newEnvPSModulePath"
}

if ($newEnvPSModulePath.split(";") -contains $azureModulePath) {
$newEnvPSModulePath = (($newEnvPSModulePath).Split(";") | ? { $_ -ne $azureModulePath }) -join ";"
write-verbose "$azureModulePath removed. Restart the prompt for the changes to take effect."
}
else {
write-verbose "$azureModulePath is not present in $newEnvPSModulePath"

foreach ($modulePath in $modulePaths) {
if ($newEnvPSModulePath.split(";") -contains $modulePath) {
$newEnvPSModulePath = (($newEnvPSModulePath).Split(";") | ? { $_ -ne $modulePath }) -join ";"
Write-Verbose "$modulePath removed. Restart the prompt for the changes to take effect."
}
else {
Write-Verbose "$modulePath is not present in $newEnvPSModulePath"
}
}

if (Test-Path "C:\Modules\az_*") {
$azPSModulePath = (Get-ChildItem "C:\Modules\az_*" -Directory `
| Sort-Object { [version]$_.Name.Split('_')[-1] } `
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureFileCopyV6/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"version": {
"Major": 6,
"Minor": 241,
"Patch": 0
"Patch": 2
},
"demands": [
"azureps"
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureFileCopyV6/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"version": {
"Major": 6,
"Minor": 241,
"Patch": 0
"Patch": 2
},
"demands": [
"azureps"
Expand Down
33 changes: 16 additions & 17 deletions Tasks/AzurePowerShellV4/Utility.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -178,25 +178,24 @@ function Get-LatestModuleLinux {
}

function CleanUp-PSModulePathForHostedAgent {
# Define the module paths to clean up
$modulePaths = @(
"C:\Modules\azurerm_2.1.0",
"C:\\Modules\azurerm_2.1.0",
"C:\Modules\azure_2.1.0",
"C:\\Modules\azure_2.1.0"
)

# Clean up PSModulePath for hosted agent
$azureRMModulePath = "C:\Modules\azurerm_2.1.0"
$azureModulePath = "C:\Modules\azure_2.1.0"
$azPSModulePath = $env:PSModulePath

if ($azPSModulePath.split(";") -contains $azureRMModulePath) {
$azPSModulePath = (($azPSModulePath).Split(";") | ? { $_ -ne $azureRMModulePath }) -join ";"
write-verbose "$azureRMModulePath removed. Restart the prompt for the changes to take effect."
}
else {
write-verbose "$azureRMModulePath is not present in $azPSModulePath"
}

if ($azPSModulePath.split(";") -contains $azureModulePath) {
$azPSModulePath = (($azPSModulePath).Split(";") | ? { $_ -ne $azureModulePath }) -join ";"
write-verbose "$azureModulePath removed. Restart the prompt for the changes to take effect."
}
else {
write-verbose "$azureModulePath is not present in $azPSModulePath"
foreach ($modulePath in $modulePaths) {
if ($azPSModulePath.split(";") -contains $modulePath) {
$azPSModulePath = (($azPSModulePath).Split(";") | ? { $_ -ne $modulePath }) -join ";"
Write-Verbose "$modulePath removed. Restart the prompt for the changes to take effect."
}
else {
Write-Verbose "$modulePath is not present in $azPSModulePath"
}
}

$env:PSModulePath = $azPSModulePath
Expand Down
10 changes: 5 additions & 5 deletions Tasks/AzurePowerShellV4/_buildConfigs/Node20/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"agent-base": "6.0.2",
"azure-pipelines-task-lib": "^4.11.0",
"azure-pipelines-tasks-azure-arm-rest": "^3.239.0",
"azure-pipelines-tasks-utility-common": "^3.225.0"
"azure-pipelines-tasks-utility-common": "^3.238.0"
},
"devDependencies": {
"typescript": "5.1.6"
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzurePowerShellV4/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"version": {
"Major": 4,
"Minor": 241,
"Patch": 0
"Patch": 2
},
"releaseNotes": "Added support for Az Module and cross platform agents.",
"groups": [
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzurePowerShellV4/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"version": {
"Major": 4,
"Minor": 241,
"Patch": 0
"Patch": 2
},
"releaseNotes": "ms-resource:loc.releaseNotes",
"groups": [
Expand Down
33 changes: 16 additions & 17 deletions Tasks/AzurePowerShellV5/Utility.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -178,25 +178,24 @@ function Get-LatestModuleLinux {
}

function CleanUp-PSModulePathForHostedAgent {
# Define the module paths to clean up
$modulePaths = @(
"C:\Modules\azurerm_2.1.0",
"C:\\Modules\azurerm_2.1.0",
"C:\Modules\azure_2.1.0",
"C:\\Modules\azure_2.1.0"
)

# Clean up PSModulePath for hosted agent
$azureRMModulePath = "C:\Modules\azurerm_2.1.0"
$azureModulePath = "C:\Modules\azure_2.1.0"
$azPSModulePath = $env:PSModulePath

if ($azPSModulePath.split(";") -contains $azureRMModulePath) {
$azPSModulePath = (($azPSModulePath).Split(";") | ? { $_ -ne $azureRMModulePath }) -join ";"
write-verbose "$azureRMModulePath removed. Restart the prompt for the changes to take effect."
}
else {
write-verbose "$azureRMModulePath is not present in $azPSModulePath"
}

if ($azPSModulePath.split(";") -contains $azureModulePath) {
$azPSModulePath = (($azPSModulePath).Split(";") | ? { $_ -ne $azureModulePath }) -join ";"
write-verbose "$azureModulePath removed. Restart the prompt for the changes to take effect."
}
else {
write-verbose "$azureModulePath is not present in $azPSModulePath"
foreach ($modulePath in $modulePaths) {
if ($azPSModulePath.split(";") -contains $modulePath) {
$azPSModulePath = (($azPSModulePath).Split(";") | ? { $_ -ne $modulePath }) -join ";"
Write-Verbose "$modulePath removed. Restart the prompt for the changes to take effect."
}
else {
Write-Verbose "$modulePath is not present in $azPSModulePath"
}
}

$env:PSModulePath = $azPSModulePath
Expand Down
14 changes: 7 additions & 7 deletions Tasks/AzurePowerShellV5/_buildConfigs/Node20/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"agent-base": "6.0.2",
"azure-pipelines-task-lib": "^4.11.0",
"azure-pipelines-tasks-azure-arm-rest": "^3.239.0",
"azure-pipelines-tasks-utility-common": "^3.225.0"
"azure-pipelines-tasks-utility-common": "^3.238.0"
},
"devDependencies": {
"typescript": "5.1.6"
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzurePowerShellV5/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"version": {
"Major": 5,
"Minor": 241,
"Patch": 0
"Patch": 2
},
"releaseNotes": "Added support for Az Module and cross platform agents.",
"groups": [
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzurePowerShellV5/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"version": {
"Major": 5,
"Minor": 241,
"Patch": 0
"Patch": 2
},
"releaseNotes": "ms-resource:loc.releaseNotes",
"groups": [
Expand Down
4 changes: 2 additions & 2 deletions _generated/AzureFileCopyV4.versionmap.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Default|4.241.0
Node20_229_2|4.241.1
Default|4.241.2
Node20_229_2|4.241.3
Loading