Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I clone a .NET solution?

Starting new .NET projects always involves a bit of work. You have to create the solution, add projects for different tiers (Domain, DAL, Web, Test), set up references, solution structure, copy javascript files, css templates and master pages etc etc.

What I'd like is an easy way of cloning any given solution.

If you use copy/paste, the problem is that you need to then go through renaming namespaces, assembly names, solution names, GUIDs etc.

Is there a way of automating this?

Something like this would be great:

solutionclone.exe --solution=c:\code\abc\template.sln --to=c:\code\xyz --newname=MySolution 

I'm aware that Visual Studio has project templates, but I've not seen solution templates.

like image 297
tobinharris Avatar asked Oct 03 '08 09:10

tobinharris


People also ask

How do I clone a solution in Visual Studio?

Use the start window Open Visual Studio. On the start window, select Clone a repository. Enter or type the repository location, and then select the Clone button. You might be asked for your user sign-in information in the Git User Information dialog box.

How do you clone in C#?

C# | Clone() Method In C#, Clone() is a String method. It is used to clone the string object, which returns another copy of that data. In other words, it returns a reference to this instance of String. The return value will be only another view of the same data.

How do I open a Visual Studio project without solution?

You can open code into Visual Studio in the following ways: On the Visual Studio menu bar, choose File > Open > Folder, and then browse to the code location. On the context (right-click) menu of a folder containing code, choose the Open in Visual Studio command. Choose the Open Folder link on the start window.


3 Answers

I have created a small application for this. It works just like the previously mentioned Solutionclone app, except that it is both a command line application as well as a WPF application.

Cloney copies a source folder to a target one, without any Git or Svn integration. It will also replace the old namespace everywhere (in file names as well as within files) with the new namespace (the name of the target folder) and exclude certain files (e.g. *.suo, *.user, *.vssscc) and folders (e.g. .git, .svn).

You can grab the source code or download an executable at https://github.com/danielsaidi/cloney.

Cloney can also be added to the Windows Explorer context menu, which makes it possible to clone .NET solutions by just right-clicking the .sln file.

like image 107
Daniel Saidi Avatar answered Sep 18 '22 20:09

Daniel Saidi


As you already found out: Copy the .sln File and make sure the paths/guids match.

Because the .sln are text/plain just use your favourite scripting language to script a cloner.

Maybe this is a good time to learn Python/Ruby/Perl/Windows Script Host

MSDN Solution (.sln) File Definition

like image 36
Andre Bossard Avatar answered Sep 17 '22 20:09

Andre Bossard


Look at Tree Surgeon on CodePlex, it creates a development tree for you.

like image 29
Stuart McConnell Avatar answered Sep 21 '22 20:09

Stuart McConnell