Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing folder names in Visual Studio when using SVN

I am using VS2008/VS2010 with Resharper 5, TortoiseSVN 1.6.8.19260-x64, and AnkhSVN 2.1.8420.8. Most operations I do in Visual Studio are reflected fine in SVN, however, renaming folders in a project can cause problems when I try to submit my changes. Also all the namespaces in the C# source files under the renamed folder need to be updated to reflect the name change.

What is the best way to rename the main project folder or any sub folders and ensure there are no issues with SVN? Should it be done outside Visual Studio?

What is the best way to update all the namespace changes? Is search/replace the only way?

Are there any best practices regarding folder names and their contents?

like image 263
Piers Myers Avatar asked May 16 '10 21:05

Piers Myers


People also ask

How do I change a folder name in Visual Studio?

Summary Steps Rename the folder(s) outside Visual Studio. Open the solution in Visual Studio, ignoring the warnings. Go through all unavailable projects and click “F4” key view project properties. Set the file path to the new folder location.

How do I change a filename in SVN?

Renaming a file. Normally you can just use SVN Rename on the context menu. This is analogous to the Move command described in the Moving or Copying a file recipe. It is almost as if you are doing two separate steps: an Add operation with the new name and a Delete operation of the old name.

How do I Rename a folder in Visual Studio Solution Explorer?

The same for the assembly and namespace names. Alternate step 7: Open the SLN file with VS, ignore warnings (click "OK"), select the project(s) in Solution Explorer, hit F4, update the file path. Optional Step 0: Right-click solution and rename it. This worked for me on Visual Studio Community 2017.


3 Answers

Yes do your rename outside of Visual Studio.

Using TortoiseSVN in windows explorer, do your rename via the TortoiseSVN context menu on the folder in question. The project in Visual Studio will detect the changes on disk and ask you to reload.

You could also do an exclude from project in Visual Studio, then rename and then re-include the new path.

Edit: As per @Sander Rijken below, AnkhSVN tracks the rename and makes sure the rename is correctly registered in the svn working copy.
If you don't have AnkhSVN installed in addition to TortoiseSVN though this will not work and you have to do as I said above.

like image 72
Brian R. Bondy Avatar answered Sep 22 '22 18:09

Brian R. Bondy


You should be able to rename folders inside Visual Studio when running AnkhSvn. Also when using refactoring tools like Resharper to change the namespace according to the new folder name, everything works as expected for me.

like image 37
Sander Rijken Avatar answered Sep 24 '22 18:09

Sander Rijken


The Agent SVN plug-in implements the MS-SCCI interface which allows it to integrate with Visual Studio.

Since the MS-SCCI defines a file rename operation, that means Agent SVN can do file renames from within the IDE, as should any plug-in that also implements the MS-SCCI.

like image 42
jussij Avatar answered Sep 21 '22 18:09

jussij