Big McLargeHuge
Big McLargeHuge

Reputation: 16056

How can I use a class from a project without including the project in my solution?

I have a web solution that looks like this:

Domain (solution folder)

    Artemis.Core (project in solution)
        Interfaces (project folder)
            IRepository.cs
        Address.cs
        ...
        User.cs

    Artemis.Data (project in solution)
        Repository.cs

Artemis.User (project in solution)
    IUserOrderTask.cs
    IUserProfileTask.cs
      ...

Artemis.Tasks.User (project in solution)
    UserOrderTask.cs
    UserProfileTask.cs
    ...

Artemis.WebSite (project in solution)
   Controllers (project folder)
   Models (project folder)
   Views (project folder)
   ...

There's a lot of other projects and files in this solution. It's a complex web of dependencies that I've been asked to reduce. Here are the dependencies of each project, ordered by amount:

Artemis.WebSite depends on:

Artemis.Tasks.User depends on:

Artemis.User and Artemis.Data depend on:

Finally Artemis.Core depends on nothing.

My task is to remove everything from the solution that Artemis.WebSite doesn't explicitly depend on. Most of these projects are used in several solutions for other web sites, so removing all the stuff from Artemis.Core except User.cs (for instance) is not an option.

How can I do this without modifying the projects?

Upvotes: 0

Views: 53

Answers (1)

Nathan A
Nathan A

Reputation: 11319

You can add specific CS files as links to projects, which would bring in a class without touching the original project, or copy the file.

  1. Right-click target project
  2. Select Add Existing Item...
  3. Select CS file you want to "add".
  4. DO NOT CLICK ADD
  5. Click drop down arrow next to Add and select Add as Link.

Upvotes: 4

Related Questions