-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdotnet-clean.ps1
30 lines (26 loc) · 900 Bytes
/
dotnet-clean.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# This script clears dotnet core publish directory
[CmdletBinding()]
Param (
# Defines the publish directory name
[parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[String] $directory,
# Defines the full path for working directory context
[parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[String] $workingdirectory
)
# Determines the context of working directory
if(Test-Path $workingdirectory){
Set-Location $workingdirectory
}
else{
Write-Host "Provided working directory does not exists"
Write-Host "Proceeding in the current directory: $pwd"
}
# Clears all files present in the publish directory
foreach($Item in (Get-ChildItem -Recurse -Directory | Where {$_.Name -eq $directory})){
Write-Host "Removing $($item.FullName)"
Remove-Item $($Item.FullName) -Force -Recurse -ErrorAction SilentlyContinue
}
Write-Host "End of script."