setup-dotnet/__tests__/clear-toolcache.ps1

25 lines
660 B
PowerShell
Raw Normal View History

2021-02-03 19:13:32 +07:00
$os = $args[0]
2021-02-03 19:31:11 +07:00
$linuxDotnetPaths = @("/usr/share/dotnet", "$env:HOME/.dotnet")
$macOSDotnetPaths = @("$env:HOME/.dotnet")
2021-02-03 21:03:23 +07:00
$windowsDotnetPaths = @("$env:HOME\.dotnet",
2021-02-03 19:31:11 +07:00
"$env:ProgramFiles\dotnet/*",
2021-02-03 21:03:23 +07:00
"$env:LocalAppData\Microsoft\dotnet/*")
2021-02-03 19:13:32 +07:00
$pathsToClear = @()
2021-02-03 19:17:48 +07:00
if ($os -eq "Linux") {
2021-02-03 19:13:32 +07:00
$pathsToClear = $linuxDotnetPaths
2021-02-03 19:15:56 +07:00
} elseif ($os -eq "macOS") {
2021-02-03 19:13:32 +07:00
$pathsToClear = $macOSDotnetPaths
2021-02-03 19:17:48 +07:00
} elseif ($os -eq "Windows") {
2021-02-03 19:13:32 +07:00
$pathsToClear = $windowsDotnetPaths
}
foreach ($path in $pathsToClear) {
if (Test-Path $path) {
2021-02-03 19:20:22 +07:00
Write-Host "Clear $path path"
2021-02-03 21:46:39 +07:00
Remove-Item $path -Recurse -Force
2021-02-03 19:13:32 +07:00
}
}