Search code examples
visual-studiomaui

How do I add an external project to a .net MAUI solution?


We have a suite of .net MAUI apps which all use the same back end services, data models, etc.

We use Visual Studio and are looking for how to separate all of the shared code, put it in a separate project, and then somehow attach that to each app Solution may be as a DLL or something.

Many thanks for any help you can offer!


Solution

  • What you need to create is a .NET MAUI Class Library. You can find relevant project template available in Visual Studio.

    Within this class library, include all the shared code, such as backend service implementations, data models, and any other common functionality.

    Now In each .NET MAUI application that needs to utilize the shared code, add a reference to the class library:

    • Right-click on the MAUI project in Solution Explorer.
    • Select "Add" > "Project Reference."
    • Choose the class library project and click "OK."