Remove pre-installed Pester module (#25304)
This commit is contained in:
Родитель
08f4500639
Коммит
0b742d6330
|
@ -538,9 +538,14 @@ namespace Microsoft.Azure.Commands.TestFx
|
|||
output = powershell.Invoke();
|
||||
watch.Stop();
|
||||
|
||||
var resultFormatting = watch.ElapsedMilliseconds < 5000 ? "##[section]" : "##[warning]";
|
||||
|
||||
Console.WriteLine($"{resultFormatting}Test {testName} completed in {watch.ElapsedMilliseconds}ms");
|
||||
if (watch.ElapsedMilliseconds < 5000)
|
||||
{
|
||||
Console.WriteLine($"INFO : Test {testName} completed in {watch.ElapsedMilliseconds}ms");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine($"##[warning]WARNING : Test {testName} completed in {watch.ElapsedMilliseconds}ms");
|
||||
}
|
||||
|
||||
if (powershell.Streams.Error.Count > 0)
|
||||
{
|
||||
|
|
|
@ -2,19 +2,49 @@ function RemovePreInstalledModule {
|
|||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(Mandatory, Position = 0)]
|
||||
[Alias("ModuleName")]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string] $Name
|
||||
[hashtable] $ModuleToRemove
|
||||
)
|
||||
|
||||
# Remove Az modules
|
||||
Get-Module -Name $Name* -ListAvailable | ForEach-Object {
|
||||
$moduleDirectory = $_.Path | Split-Path | Split-Path
|
||||
if (Test-Path -LiteralPath $moduleDirectory) {
|
||||
Remove-Item -LiteralPath $moduleDirectory -Recurse -Force
|
||||
$ModuleToRemove.Keys | ForEach-Object {
|
||||
$moduleName = $_
|
||||
$moduleVersion = $ModuleToRemove[$moduleName]
|
||||
|
||||
Write-Host "##[group]Processing module $moduleName"
|
||||
|
||||
Write-Host "All installed modules with name $moduleName :"
|
||||
Get-Module -Name $moduleName -ListAvailable
|
||||
Write-Host
|
||||
|
||||
$modules = Get-Module -Name $moduleName -ListAvailable | Where-Object Version -gt ([Version]$moduleVersion)
|
||||
$modules | ForEach-Object {
|
||||
$installedModule = $_
|
||||
$installedModuleName = $installedModule.Name
|
||||
|
||||
Write-Host "##[section]Unqualified pre-installed module is $installedModuleName with version $($installedModule.Version)."
|
||||
$installedModule | Format-List
|
||||
|
||||
$moduleDirectory = $installedModule.Path | Split-Path | Split-Path
|
||||
if (Test-Path -Path $moduleDirectory) {
|
||||
Write-Host "##[section]Start to remove module located in $moduleDirectory."
|
||||
Remove-Item -Path $moduleDirectory -Recurse -Force -ErrorAction SilentlyContinue
|
||||
Write-Host "##[section]Module $installedModuleName has been removed."
|
||||
Write-Host
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host "##[endgroup]"
|
||||
Write-Host
|
||||
}
|
||||
}
|
||||
|
||||
RemovePreInstalledModule -Name Az
|
||||
RemovePreInstalledModule -Name AzureRM
|
||||
$modulesToRemove = @{
|
||||
"Az" = "0.0.0.0";
|
||||
"Az.*" = "0.0.0.0";
|
||||
"Azure" = "0.0.0.0";
|
||||
"Azure.*" = "0.0.0.0";
|
||||
"AzureRM" = "0.0.0.0";
|
||||
"AzureRM.*" = "0.0.0.0";
|
||||
"Pester" = "4.10.1.0"
|
||||
}
|
||||
RemovePreInstalledModule -ModuleToRemove $modulesToRemove
|
||||
|
|
Загрузка…
Ссылка в новой задаче