Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to best change directory structure (of sln and projects) in a c# project

I’m working on a c# project, lately we decided to restructure the directories structure of the source code. I’m doing the restructure and wanted to ask you some questions about what is the best way to conduct the change. The restructure is basically changing the current directories of all the projects to a more structured and logical order.

The current structure is (this is a scheme):

  • Main Dir:

    • Project
    • Project
    • Dir
      • Project
      • Project
      • Project
    • Dir
      • Project
      • Project
      • Project
    • Project Dir + solution file
    • Project Dir + solution file
    • Dir
      • Solution file.
      • Project
      • Project
    • Project Dir Etc..

The Target scheme is: TFS Project: Main - Source - Dir - Solution file. - Project - Project - Project - Project

     - Dir
        - Dir
            - Project
            - Project
            - Project
        - Dir
            - Solution file.
      - Dir

        - Project
        - Project

The relative location between the projects is changed and also the relative locations in the solutions.

The question is how to make change in the best manner: - How to Fix all the references of each project? - How to fix all the solutions? - Is there any tool available for that?

like image 250
Clueless Avatar asked Sep 17 '25 09:09

Clueless


1 Answers

If using option 2:

Move your non csproj/sln files to their target locations, make sure you understand the relative changes in your paths.

A couple of additions:

  1. I'd have the script perform the required file operations as well. Of course, make sure to back up your original solution first.
  2. .sln files are not XML. They are text files with a pretty straightforward syntax, though. So, either you'll have to write your own parser, or consider using Visual Studio's DTE automation object to manipulate the contents of the solution file as shown in this thread: Easy way to add multiple existing .csproj to a Visual Studio Solution?. The sample is written in PowerShell but the approach would be the same in, say, VBScript.
like image 91
DmytroL Avatar answered Sep 20 '25 00:09

DmytroL