This repository contains two PowerShell scripts designed to help developers easily rename C# projects, such as MAUI or WPF projects, within Visual Studio. The scripts automate the process of replacing content within files, renaming files, renaming folders, and removing source control bindings, making it especially useful when rebranding or restructuring projects.
- Delete Unnecessary Folders: Automatically removes
binandobjfolders and their contents, except withinResourcesfolders. - Replace Content in Files: Searches for and replaces specified old content with new content in all files, excluding those in
Resourcesfolders. - Rename Files: Renames files by replacing specified old content with new content in the filenames, excluding those in
Resourcesfolders. - Rename Folders: Renames folders by replacing specified old content with new content in the folder names, excluding those in
Resourcesfolders. - Remove Source Control Bindings: Removes Team Foundation Version Control (TFVC) bindings from solution files and deletes related source control files (
.vspsccand.vssscc).
Before running the scripts, you need to set up your PowerShell environment to allow script execution and ensure you run the script with administrative privileges.
To enable the execution of PowerShell scripts, you need to set the execution policy. Open PowerShell as an administrator and run the following command:
Set-ExecutionPolicy RemoteSignedYou may need to confirm the change by typing Y and pressing Enter.
To run the script with the necessary permissions, you need to open PowerShell as an administrator:
- Click on the Start menu.
- Type
powershell. - Right-click on
Windows PowerShelland selectRun as administrator.
-
Clone the Repository:
git clone https://github.com/abeginnDev/RenameVsProjekts.git cd RenameVsProjekts -
Run the Appropriate Script: Depending on your needs, choose one of the scripts to run:
This script handles folder cleanup, content replacement, file renaming, and folder renaming.
.\RenameProject.ps1
This script includes all the features of
RenameProject.ps1plus the removal of source control bindings and related files..\RenameAndCleanProject.ps1
-
Follow the Prompts: The script will prompt you to:
- Enter the path to the main folder of your project.
- Specify the old content to be replaced.
- Specify the new content to replace the old content.
-
Watch the Script Work: The script will then:
- Delete
binandobjfolders. - Remove TFVC bindings from solution files (only in
RenameAndCleanProject.ps1). - Remove source control files (only in
RenameAndCleanProject.ps1). - Replace the specified old content with new content in all applicable files.
- Rename files and folders accordingly.
- Delete
-
Completion: The script will display the number of replaced contents, filenames, and folders upon completion.
Imagine you want to rename a project from "OldProject" to "NewProject":
- You will be prompted to enter the path to the main folder, such as
C:\Projects\OldProject. - Enter "OldProject" as the old content and "NewProject" as the new content.
- The script will handle the rest, updating all relevant files, filenames, and folder names.
- Ensure you have a backup of your project before running the script.
- The script excludes changes in the
Resourcesfolder to preserve resource integrity.
Feel free to fork the repository and submit pull requests. Contributions are welcome!
This project is licensed under the MIT License.