Visual Studio Copy Project
It is highly NOT ADVISABLE to copy projects at all because the some config files formed internally like .csproj, .vspscc etc. may (and most probably will) point to references which belong to previous solutions' location and other paths/locations in system or TFS. Unless you are an expert at reading these files and fixing references, do not try to copy projects.
You can create a skeletal project of the same type you intend to copy, this creates a proper .csproj, .vspscc files. Now you are free to copy the class files,scripts and other content from the previous project as they will not impact. This will ensure a smooth build and version control (should you choose to be interested in that)
Having said all this, let me give you the method to copy project anyhow in a step-wise manner:
- Go to the project you want to copy in solution explorer and right-click.
- Now select 'Open Folder in File Explorer' (Assuming you have the solution mapped to a local path on your disk).
- Select the Projects you want to replicate as whole folders(along with all dependencies,bin .vspscc file, .csproj file)
- Paste them in your desired location (it could be your same solution folder or even another solution folder. If it is within the same solution folder, then you would be required to rename it, also the .csproj and other internal files to the new name).
- No go back to Visual Studio, Right-Click on Solution > Add > Existing Project...
- Browse and select the Project file (.csproj file) now from the location you placed it in and select 'open'
- This file now appears in the solution explorer for you to work.
You may now have to resolve a few build errors probably with duplicated/missing references and stuff but otherwise it's as pristine in logic and structure as you expected it to be.
If you want a copy, the fastest way of doing this would be to save the project. Then make a copy of the entire thing on the File System. Go back into Visual Studio and open the copy (by right clicking on solution => add existing project => open the copied project). From there, I would most likely recommend re-naming the project/solution (Steps of Safely Renaming Project are in the following link) so that you don't have two of the same name, but that is the fastest way to make a copy.
Just create a template;
From your project choose: Project - Export Template
The wizard will let you define
- Template name
- Template Description
- Icon
- Preview image
Then it zips up your project into 'My Exported Templates' directory. You also have the option to make your template available when you create a new project.
When you use your template to create a new project, the namespace will be correct for 'your_new_project_name' throughout every file, all references correct, everything perfecto :)
You can send the .zip file to anybody, and they must copy (not unzip) the .zip file into Templates\ProjectTemplates directory for them to use too.
I made an ASP.NET MVC template with folders, layout page, viewmodels etc arranged just how I like them.
NOTE:
If you have an empty folder in your project, it WON'T be added to the template, so I just added an empty class appropriate to each folder, and a sample picture for images folder.
I guess if this is something you do often, there's a little (non-free) utility that promises to do it for you: I haven't used it, so not sure how good it is:
http://www.kinook.com/CopyWiz/
There is also this project on CodePlex:
http://clone.codeplex.com/
I will probably give the codeplex project a try, and if it doesn't work I'll manually rename everything and edit the sln file.