Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to work with multiple projects / solutions in Visual Studio?

Tags:

Currently I have 4 solutions that are independent projects, however there is quite a bit of duplicated code when it comes to a few areas of the applications.

At the moment it is simply a few forms and their associated code.

When I want to change or improve something, I have to copy and paste to all relevant projects.

I looked at creating a new project within one of the solutions for the .dll/class library, but I felt that this was incorrect. (Please say if I am wrong).

As it is a component for all the applications, I decided to create a new solution for the .dll/class library and am looking at moving the shared code over to that - but, having never gone down this route before, what are my options from here?

Am I able to then include this solution within the others if I need to make a simple change and have it updated in all the projects or instead, should I always be working on the shared component in a separate instance of Visual Studio, outside of the applications using it?

like image 525
Wil Avatar asked Aug 01 '10 21:08

Wil


People also ask

Can a Visual Studio solution contain multiple projects?

When you create a new project, Visual Studio creates a solution to contain the project. You can then add other new or existing projects to the solution if you want.

Can you have two solutions open at once in Visual Studio?

You can have multiple projects in one instance of Visual Studio. The point of a VS solution is to bring together all the projects you want to work with in one place, so you can't have multiple solutions in one instance. You'd have to open each solution separately.


2 Answers

That's exactly the right way to handle this situation.

You can include projects in multiple solutions by right-clicking the solution and selecting Add Existing Project...

Any changes you then make will appear in all solutions. The only problem this leads to is that it's possible to break one solution from another. This is where automated builds on commit to source control come into their own.

like image 80
pdr Avatar answered Oct 12 '22 03:10

pdr


  1. Put shared codes in separate Solution/Project as Class Library,
  2. In post build event of shared projects copy dll's to a specific directory,
  3. Add shared dll's from this directory to other projects/solutions

By doing this each time you build your consumer projects, they will use latest dll's automatically.

like image 40
Afshar Mohebi Avatar answered Oct 12 '22 03:10

Afshar Mohebi