How to copy and rename a solution under source con

2019-02-24 17:54发布

问题:

I have a VS2013 solution called ShoppingService.sln with 7 projects under TFS source control. Now I want to make a copy of the solution, rename it to 'BasketService.sln' and have it under source control again. I don't want to make branches of the original solution, since both solutions should co-exist separate from each other.

What's the quickest or best way to do this?

回答1:

Ok, here's what I ended up doing:

  1. Copy entire solution folder to new location.
  2. Remove any source control files. They begin with *.vs.
  3. Remove any read-only attributes on folders and files.
  4. Open solution from new folder and rename solution and each project.
  5. Open properties for each project and edit assembly name and default namespace.
  6. Close solution.
  7. Rename folders on disk.
  8. Edit solution file in a texteditor. Replace all references with new folder names, and remove team foundation section in .sln.
  9. Open solution again in VS and fix any leftover issues. I use Resharper to fix new namespaces.
  10. Search through all files for your old solution/folder name and update with new name
  11. Consider deleting the obj and bin folders to force Visual Studio to regenerate all of those files during a build
  12. Add solution to source control again.

And you're done.



回答2:

Step 8a. Open all Project files (e.g. .CSPROJ, .projitems) in a text editor and edit folder pathnames to point to the new solution's folders.



回答3:

Quickest

File --> save solution As. 'BasketService.sln'

Right Click Solution --> Add to source control.

Right click Solution --> Check In