Scenario: I want to create and publish a library.
In the Java world: Using Gradle, I create a project using the java-library Gradle plugin. I can specify the dependencies using both the api configuration and the implementation configuration. This approach has these properties:
- When compiling the library, the direct dependencies are resolved, but the transitive dependencies are only resolved if they are required for the compilation process. This makes the resolution process a lot faster, however, version conflicts might remain hidden until the library actually needs to run.
- Consumers of my library can benefit from this behavior as well, since they only need the
apidependencies of my library to compile their library/application.
In the .NET world: Using nuget, I personally didn't come across the same distinction. There seems to be A) only one kind of dependency (no distinction between API and implementation), and B) there is no similar concept to the compile and runtime classpaths as in Java. This also means that in order to compile the library, all dependencies - direct and transitive - are resolved, even if most of those are not required at all.
Question: Is there really no similar distinction in .NET? And if not, is there any good reason for it?