Search code examples
c#visual-studioprojects-and-solutionsvisual-studio-project

How to include functionality from one project into another in the same solution?


In my company, we are creating C# client/server applications as follows:
We create three project inside one single Visual Studio solution:

  • Product.General
  • Product.Client
  • Product.Server

The "General" project contains functionality, to be used by both client and server parts.

In order to make this work, we compile the "Product.General" and add the binary as a reference to the "Product.Client" and "Product.Server" projects.

In our source code, this looks as follows:

In the "General" project:

namespace Product.Customer.Configuration
{
    public class SettingManager
    {
        ...
    }
}

In the "Server" project:

using Product.Customer.Configuration;
...
var settingManager = ...<SettingManager>();

I don't like, because amongst other first you need to get the "General" part compiled before you can even start working on your "Client" or "Server" project.

How can I get such a system to work, without needing to add compiled binaries into projects' references?
Thanks in advance


Solution

  • You should add the reference with Add Project Reference and then select the General Project like this. and whenever you are making changes just do Ctrl+Shift+B to build the solution.

    enter image description here

    enter image description here