I'm a newcomer to .NET world, and at this point I'm super confused about the packages, references and how to reference them in my c# project.
I have 3 project in my solution:
DataAccess
- which contains the logic for accessing data, the mapping between DTOs and entities, etc.,DataAccessTest
- contains unit tests forDataAccess
project,Service
- wraps theDataAccess
project into a Windows service.
Now, DataAccess
project references AutoMapper (among others) to help with data transformation. It's included in <PackageReference />
element in the csproj
file. It seems to be working fine when I'm doing dotnet restore
, however dotnet build
fails when trying to resolve the namespaces! The same goes for JetBrains Rider - it doesn't find the namespaces until I explicitly reference them in <Reference>
!
Not sure if related, but the same goes for the dependent projects. For example, DataAccessTest
references the DataAccess
project - so that the test will run. However, it still requires adding the transitive dependencies (for example AutoMapper), on top of the project reference.
Is this the intended behavior? Do you need to keep both <PackageReference>
and <Reference>
for project to compile correctly?