Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sync Visual Studio folder/filename structure with file system structure/filenames

I've made a lot of changes (a.k.a refactoring) to my (big) visual studio solution and it appears now that vs solution structure is very different in visual studio from what it is on the disk and TFS.

Is there a way to make file system (and TFS) have the same folder names and file names as in visual studio solution with some tool or script/program/helper add-in?

This is the list of main issues: - when I rename project visual studio does not rename folder where this project is located - if I move project, file to different vs folder, it just happens in visual studio, but not on the disk

like image 286
asyrov Avatar asked Feb 03 '12 00:02

asyrov


People also ask

How do I sync a folder in Visual Studio?

from the menu on the top-right corner of the Visual Studio Code IDE. You can also use a keyboard shortcut Control+Shift+P in Windows and Command+Shift+P in MacOS to open the command palette and choose Now: Sync Current File from the list.

What does sync namespace do?

It updates namespaces in your code to match folder structure. For example, if you have a file Class1. cs in folder Models it changes the code namespace in Class1. cs to Project.

How do you create a VS code folder?

Adding folders#The File > Add Folder to Workspace command brings up an Open Folder dialog to select the new folder. Once a root folder is added, the Explorer will show the new folder as a root in the File Explorer. You can right-click on any of the root folders and use the context menu to add or remove folders.


2 Answers

You can switch between logical or physical folders in the solution by clicking the "Show all files" icon (2nd top left icon in the solution pane). When not activated, you are viewing logical folders in the solution, drag and drop simply re arrange files virtually. When activated, you are viewing physical folders, drag and drop moves files on disk, using the source controller.

like image 87
Alexis Pautrot Avatar answered Nov 05 '22 07:11

Alexis Pautrot


No there are no tools that can help you do this automatically.

There is a two step approach to solve it, made easier by installing two add-ons. I prefer to use the Team Foundation Power Tools and the Source Control Explorer Extensions.

From the Source Control Window inside Visual Studio:

  1. Close the open solution in Visual Studio
  2. open the Source Control window in TFS
  3. Move the folders around to match the structure you prefer, with the mentioned add-ons you should be able to drag/drop and rename them more easily

Alternatively, do the changes on file system with the Team Foundation Power Tools explorer extensions installed:

  1. Close the solution in Visual Studio
  2. navigate to your workspace folder using Windows Explorer
  3. use the TFS context menu on the folders to check-out/rename/move the items ans folders

Then re-load the solution in Visual Studio and:

  1. Open the solution and see that a lot of projects don't load.
  2. Highlight a project that couldn't be found
  3. On the project properties window (ctrl-w, p) find the file path item and click the little [...] button to navigate to the new project file location for each project.
  4. Rightclick the projects you've updated this way in the solution explorer and reload them

Rebuild your solution to verify all changes went as expected

  1. Check-in your changes
like image 27
jessehouwing Avatar answered Nov 05 '22 08:11

jessehouwing