API Reference
Remove-ProjectFiles
Removes specific files and folders from a project directory with safety features.
Remarks
Designed for build/CI cleanup scenarios where removing generated artifacts (bin/obj, packed outputs, temporary files) should be predictable and safe. Supports -WhatIf, retries and optional backups.
Examples
Preview cleanup of build artifacts
PS>
Remove-ProjectFiles -ProjectPath '.' -ProjectType Build -WhatIf
Shows what would be removed for the selected cleanup type.
Remove custom patterns with backups enabled
PS>
Remove-ProjectFiles -ProjectPath '.' -IncludePatterns 'bin','obj','*.nupkg' -CreateBackups -BackupDirectory 'C:\Backups\MyRepo'
Creates backups before deletion and stores them under the backup directory.
Common Parameters
This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.
For more information, see about_CommonParameters.
Syntax
Remove-ProjectFiles [-BackupDirectory <String>] [-CreateBackups] [-DeleteMethod <RemoveItem|DotNetDelete|RecycleBin>] [-ExcludeDirectories <String[]>] [-ExcludePatterns <String[]>] [-Internal] [-MaxDepth <Int32>] [-PassThru] -ProjectPath <String> [-ProjectType <Build|Logs|Html|Temp|All>] [-Recurse] [-Retries <Int32>] [-ShowProgress] [<CommonParameters>]
#
ProjectTypeParameters
- BackupDirectory String
- Directory where backups should be stored (optional).
- CreateBackups SwitchParameter
- Create backup copies of items before deletion.
- DeleteMethod ProjectDeleteMethod
- Method to use for deletion.
- Possible values:
RemoveItem,DotNetDelete,RecycleBin - ExcludeDirectories String[]
- Directory names to completely exclude from processing.
- ExcludePatterns String[]
- Patterns to exclude from deletion.
- Internal SwitchParameter
- Suppress console output and use verbose/warning streams instead.
- MaxDepth Int32
- Maximum recursion depth. Default is unlimited (-1).
- PassThru SwitchParameter
- Return detailed results.
- ProjectPath String
- Path to the project directory to clean.
- ProjectType ProjectCleanupType
- Type of project cleanup to perform.
- Possible values:
Build,Logs,Html,Temp,All - Recurse SwitchParameter
- Process subdirectories recursively. Defaults to true unless explicitly specified.
- Retries Int32
- Number of retry attempts for each deletion.
- ShowProgress SwitchParameter
- Display progress information during cleanup.
Outputs
System.Object
Remove-ProjectFiles [-BackupDirectory <String>] [-CreateBackups] [-DeleteMethod <RemoveItem|DotNetDelete|RecycleBin>] [-ExcludeDirectories <String[]>] [-ExcludePatterns <String[]>] -IncludePatterns <String[]> [-Internal] [-MaxDepth <Int32>] [-PassThru] -ProjectPath <String> [-Recurse] [-Retries <Int32>] [-ShowProgress] [<CommonParameters>]
#
CustomParameters
- BackupDirectory String
- Directory where backups should be stored (optional).
- CreateBackups SwitchParameter
- Create backup copies of items before deletion.
- DeleteMethod ProjectDeleteMethod
- Method to use for deletion.
- Possible values:
RemoveItem,DotNetDelete,RecycleBin - ExcludeDirectories String[]
- Directory names to completely exclude from processing.
- ExcludePatterns String[]
- Patterns to exclude from deletion.
- IncludePatterns String[]
- File/folder patterns to include for deletion when using the Custom parameter set.
- Internal SwitchParameter
- Suppress console output and use verbose/warning streams instead.
- MaxDepth Int32
- Maximum recursion depth. Default is unlimited (-1).
- PassThru SwitchParameter
- Return detailed results.
- ProjectPath String
- Path to the project directory to clean.
- Recurse SwitchParameter
- Process subdirectories recursively. Defaults to true unless explicitly specified.
- Retries Int32
- Number of retry attempts for each deletion.
- ShowProgress SwitchParameter
- Display progress information during cleanup.
Outputs
System.Object