Referencing Projects in Visual Studio 2017

I am confused about how VS 2017 calculates project references. It uses the new csproj file format.

I have a solution that has many related class library projects. These projects use other general purpose libraries that I have written. Some of these general purpose libraries, in turn, use other libraries. Conceptually, the structure looks like this:

Class library A -> uses support library SL1 -> uses support library SL1a -> uses support library X

Class library B => uses support library SL2 -> uses support library SL2a -> uses support library Y

The key point is that neither class library A nor class library B uses the X or Y helper library directly.

However, unless I specifically include X & Y libraries in the solution, I get recognizer errors complaining about the inability to find objects defined in X or Y library when I try to compile class library A or B.

I thought the files would .csproj

take care of all this while instructing VS 2017 on how to find the source code to support the X & Y libraries (they are all available on my local filesystem and the paths in the files .csproj

all use absolute paths).

I am clearly missing something. Of course, it is not difficult to add specific project references for X & Y libraries . But I would like to understand why I should do this.

Here is an excerpt from a .csproj

Typical Class Library A file that links to DatabaseJobFramework :

  <ItemGroup>
    <ProjectReference Include="C:\Programming\WebJobs\src\DatabaseJobFramework\DatabaseJobFramework.csproj" />
    <ProjectReference Include="C:\Programming\CampaignSystem\src\CampaignDb\CampaignDb.csproj" />
    <ProjectReference Include="C:\Programming\CampaignSystem\src\CampaignMessaging\CampaignMessaging.csproj" />
  </ItemGroup>

      

Here's an excerpt from DatabaseJobFramework.csproj , a typical SL1 helper library :

  <ItemGroup>
    <ProjectReference Include="C:\Programming\WebJobs\src\ImportFramework\ImportFramework.csproj" />
    <ProjectReference Include="C:\Programming\WebJobs\src\JobFramework\JobFramework.csproj" />
    <ProjectReference Include="C:\Programming\WebJobs\src\JobMessaging\JobMessaging.csproj" />
  </ItemGroup>

      

Here's an excerpt from ImportFramework.csproj , a typical SL1a helper library :

  <ItemGroup>
    <ProjectReference Include="C:\Programming\UtilityLibraries\src\SpecializedCollections\SpecializedCollections.csproj" />
    <ProjectReference Include="C:\Programming\UtilityLibraries\src\SystemUtils\SystemUtils.csproj" />
    <ProjectReference Include="C:\Programming\DataLibraries\src\dBaseIII\dBaseIII.csproj" />
  </ItemGroup>

      

SystemUtils , a typical X library , is independent of the code I write; all its links refer to system libraries (for example Microsoft.CSharp

, System

)

Additional Information

A workaround that I use involves adding a reference to the project the X (class library the X ; SystemUtils in my example) to the solution, even if it already has a link to a file .csproj

for the class library SL1a ( ImportFramework , in my example).

In other words, why would I need to explicitly include SystemUtils in the solution, even though I have already included ImportFramework in the solution and >> its << .csproj

file contains a reference to SystemUtils ?

+4


source to share





All Articles