setup-dotnet/__tests__/clear-toolcache.ps1

23 lines
593 B
PowerShell
Raw Normal View History

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