Project

PSPublishModule

Build, test, version, sign, and publish PowerShell modules with reusable PowerForge pipelines.

Stars 48
Forks 16
PowerShell Gallery downloads 17,213
Release v3.0.169
Language: C# Updated: 2026-10-17
Command

Remove-ProjectFiles

Module PSPublishModule
Inputs
None

Removes specific files and folders from a project directory with safety features.

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>]
#
Parameter set: ProjectType
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>]
#
Parameter set: Custom

Description

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

Authored help example

Preview cleanup of build artifacts

Remove-ProjectFiles -ProjectPath '.' -ProjectType Build -WhatIf

Shows what would be removed for the selected cleanup type.

Remove custom patterns with backups enabled

Remove-ProjectFiles -ProjectPath '.' -IncludePatterns 'bin','obj','*.nupkg' -CreateBackups -BackupDirectory 'C:\Backups\MyRepo'

Creates backups before deletion and stores them under the backup directory.

Parameters

-BackupDirectory String optional
Directory where backups should be stored (optional).
-CreateBackups SwitchParameter optional
Create backup copies of items before deletion.
-DeleteMethod ProjectDeleteMethod optional
Method to use for deletion.
Possible values: RemoveItem, DotNetDelete, RecycleBin
-ExcludeDirectories String[] optional
Directory names to completely exclude from processing.
-ExcludePatterns String[] optional
Patterns to exclude from deletion.
-Internal SwitchParameter optional
Suppress console output and use verbose/warning streams instead.
-MaxDepth Int32 optional
Maximum recursion depth. Default is unlimited (-1).
-PassThru SwitchParameter optional
Return detailed results.
-ProjectPath String required
Path to the project directory to clean.
-ProjectType ProjectCleanupType optionalsets: ProjectType
Type of project cleanup to perform.
Possible values: Build, Logs, Html, Temp, All
-Recurse SwitchParameter optional
Process subdirectories recursively. Defaults to true unless explicitly specified.
-Retries Int32 optional
Number of retry attempts for each deletion.
-ShowProgress SwitchParameter optional
Display progress information during cleanup.
-IncludePatterns String[] requiredsets: Custom
File/folder patterns to include for deletion when using the Custom parameter set.

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.