Changing folder names in Visual Studio when using SVN
Asked Answered
S

4

12

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?

Shonda answered 16/5, 2010 at 21:51 Comment(0)
G
5

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.

Garate answered 16/5, 2010 at 21:56 Comment(4)
Renaming outside of Visual Studio means you have to fix up the project file later, either by excluding and bringing in new files, or by manually editing it. When renaming in Visual Studio, it's a one step processTraduce
@Sander, but renaming in Visual Studio does not tell TortoiseSVN about the rename, this leads to lots of problems in TortoiseSVNWagram
No, the question was about using AnkhSVN. AnkhSVN tracks the rename and makes sure the rename is correctly registered in the svn working copyTraduce
@Sander: I added this info above. I would have deleted instead, but I can't since it is the accepted answer.Garate
T
3

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.

Traduce answered 10/6, 2010 at 21:38 Comment(1)
I do wonder why this was downvoted. The question was about using the Resharper, AnkhSVN, TortoiseSVN combination. With that combination renaming with or without resharper from within Visual Studio is the best way to go, because it changes both the actual folder, the project file, and the Subversion working copy.Traduce
S
3

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.

Siamang answered 29/12, 2011 at 13:47 Comment(0)
D
0

What I typically do when having to perform a folder renaming is first renaming the folder using tortoiseSVN, then Excluding/Including the folder in VS and finally renaming all the namespaces (with Resharper it's just a matter of going file by file and Alt+Enter(ing) on the namespace directive to rename as appropriate.

Danged answered 16/5, 2010 at 21:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.