Search code examples
visual-studio-2010visual-studioprojects-and-solutions

If i want to make a copy of my c# project in the same workspace how can i do it?


In other words lets say i have already completed a project using visual studio. Now i want to make a separate project that is identical to the already completed project(except for some future changes).

How can i do this while keeping the new project in the same workspace as the original without:

  • creating a new project and copy pasting code over
  • copy-pasting the folder that holds the project and changing the name of the folder

I'm asking because there must be a better way to do this than the two options above.


Solution

  • The second option is exactly what you should do: duplicate the folder containing your project and then rename it.

    To make this work, you might also have to change the GUID used by the project to avoid clashes. Visual Studio is supposed to do this automatically if another project with the same GUID already exists in the solution. If something goes wrong, you can do it manually by editing the project file (it's the field called ProjectGUID). It's just a standard GUID value, so use any freely-available GUID generator like the one bundled with Visual Studio or one you find online.

    Why should there be a better option than this? What would that "better" option look like? It's not like there's going to be a menu command for it, this isn't a very commonly used feature. Most programmers use a source control system that handles branching/duplicating for them automatically and [mostly] without pain.