简体   繁体   中英

How to correctly configure dependencies in Visual Studio - .NET

I've come across a strange situation at work, where I use the same library across multiple projects, yet not in the standard manner.

Let's assume we have a main project named, unsurprisingly, "MainProject".
We also have a shared library named "A", and another library named "B".
Say "B" is a broad utility library, which includes lots of stuff, and is used both by library "A" and by the "MainProject".

All those projects/libraries have Git as their VCS, and are configured with sub-modules as such:

MainProject:

  • Sub-module of Library B
  • Library A
    • Sub-module of Library B

Now the problem arises when trying to rebuild the solution of the "MainProject".
Visual Studio outputs the error:

Error 1 Metadata file 'LibraryA_Path\\LibraryB.dll' not found

Searching for this problem, it became clear to me that something doesn't get built as I expect it to.
And that's right - "A" doesn't build the "B" that it references probably because it's nested too deep.

Then I tried to explicitly set the reference of "A" to the "B" of the "MainProject", which solved the build issue, but forced a change in the library's Git working tree, meaning any update to this library will enforce me to do this process of manual referencing all over again.

So what is the correct way to configure this kind project? I can try anything as I'm in full control of all projects and libraries - In code and also in Git.

I am not sure if I understood you correctly, but do you reference the *.dlls that get build by the Library B project? If this is the case, replace it with a project reference on the Library B project. Visual studio then ensures that the referenced projects are build first.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM