3

Any ideas on how to move (and rename) a Visual Studio project item? I want to move (and rename) an item from one location in the hierarchy to another location in the hierarchy. I want this through automation on the Visual Studio object model, so I will not get into trouble with source control (having to checkout and checkin files).

Tim Abell
  • 11,186
  • 8
  • 79
  • 110
Serge van den Oever
  • 4,340
  • 8
  • 45
  • 66
  • possible duplicate of [How do I rename a Project Folder from within Visual Studio?](http://stackoverflow.com/questions/211241/how-do-i-rename-a-project-folder-from-within-visual-studio) – Tim Abell May 23 '14 at 22:27
  • Tim, it is not a duplicate as this question is about doing this through VS automation model. – Dmitry Pavlov May 24 '14 at 09:00
  • I think the automation thing is a red herring. There a lot of questions like this on SO and they need consolidating. If it's TFS that's the problem then it's a dupe of https://stackoverflow.com/questions/49066/renaming-the-containing-project-folder-in-vs-net-under-tfs , if it's a non-manual method they want then it's a dupe of https://stackoverflow.com/questions/6147348/visual-studio-tools-to-rename-projects-and-directories-automatically . And if they really do want to code it up themselves then I think this question needs to be a whole load clearer so should be improved or closed. – Tim Abell May 24 '14 at 20:13

1 Answers1

0

You need to do it in four steps (no other easy way):

  1. From visual studio rename the project (this renames the .VCproj file) (You can do this after step 2 if you want to track vcproj changes in source control).
  2. Remove the project from the solution (without deleting the files).
  3. Using File Explorer change the project directory name, and move it to where you want it (physically). - you can use SVN rename for this step.
  4. From visual studio add an existing project.
Henry Aloni
  • 617
  • 7
  • 24
  • This will break references from other projects. I suggest using http://stackoverflow.com/a/224788/10245 instead. – Tim Abell May 24 '14 at 20:15