I noticed when using .net core 2.2 if you add a project reference to another project those project references are available to other projects that reference the original project.
For example:
If you have a 3 projects, let's say UI, Services, and DAL. If you have a reference to Services from UI and Services has a reference to DAL. With that set up, you will notice you will be able to add a using statement and gain access to classes in the DAL project from the IU project. Whats the reasoning behind this and can it be disabled?
UI
-- project references
---- Services
Services
-- project references
---- DAL
I took @Kirk Larkin comment and made it work for me, however I had to use "ExcludeAssets" instead:
Imagine something like this:
-- GUI
---- Business layer dll
------ Data access layer dll
Inside the Business layer dll project file (csproj):
<ProjectReference Include="..\..\DALProject\DALProject\DALProject.csproj">
<ExcludeAssets>compile</ExcludeAssets>
</ProjectReference>
With this, I can no longer reference DALProject methods from my GUI layer where it's not directly referenced. This method also includes all the supporting DLL's for runtime use.
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With