Ben.Demystifier icon indicating copy to clipboard operation
Ben.Demystifier copied to clipboard

Make it a source-only Nuget package

Open dennisdoomen opened this issue 8 years ago • 16 comments
trafficstars

And I'll be happy to use it everywhere.....!

dennisdoomen avatar Oct 30 '17 11:10 dennisdoomen

Why specifically source only? Not too familiar with their advantages

benaadams avatar Oct 30 '17 12:10 benaadams

It means that my library, framework or component can take a dependency on your package without having to bother my consumers with another dependency. This blog post provides some of the rationale for that. If you want to see an example, see FluidCaching

dennisdoomen avatar Oct 30 '17 13:10 dennisdoomen

I like the idea; include the code so any dependency changes you make in your app aren't blocked by the dependencies of a package. 👍

ChrisMcKee avatar Oct 30 '17 21:10 ChrisMcKee

Was wondering how name collisions worked:

#if PUBLIC_FLUID_CACHING
    public
#else
    internal
#endif

So src package uses internal and library uses public?

benaadams avatar Oct 30 '17 21:10 benaadams

So src package uses internal and library uses public?

Yep

dennisdoomen avatar Oct 31 '17 06:10 dennisdoomen

This would be super useful if distributed as a single source file that could be dropped into any library or application. On a side note, I am the the author of the LightInject DI library and we have been providing source and binary packages for years now. source packages are internal types for the most part, binary package has public types.

btw, where is the code for this ? :)

seesharper avatar Oct 31 '17 08:10 seesharper

https://github.com/damianh/LibLog by @damianh works similarly. It's just a single file which can be copy and pasted in, or included via nuget.

That said, Dapper was also a single source file, but moved away from that approach as the maintenance burden made that impossible.

willl avatar Oct 31 '17 11:10 willl

In FluidCaching I decided to keep the files separate for easy editing and then "compiled" them together before I build the Nuget package.

dennisdoomen avatar Oct 31 '17 13:10 dennisdoomen

The single file was to reduce the noise on the consumers solution explorer. That was the old nuget content package way.

With the new sdk package reference, the files are not copied directly in the cs proj folder. As such, I will break down the file for easier maintenance.

damianh avatar Oct 31 '17 13:10 damianh

Difference between LibLog's and Dapper's needs is that LibLog becomes part of your library's API. It uses a namespace transform (.pp) file to achieve that. I don't think Dapper, FluidCaching nor this has the same need.

damianh avatar Oct 31 '17 14:10 damianh

@benaadams Does the source for this exists somewhere? I'd love to take it for a spin :)

seesharper avatar Nov 03 '17 19:11 seesharper

If it would help to see a very simple example of a source package, see https://github.com/adamralph/liteguard - it does do the .pp name transformation. However it also produces both source and binary packages, and until now, I haven't found a good way to generate the .pp from the .cs, given the platform-specific #ifs, so I simply hand crafted the .pp files from the .cs and committed them. The code is very small and almost never changes, so it's easy in this case.

adamralph avatar Nov 03 '17 19:11 adamralph

@dennisdoomen do you have an example of how/where you'd use it; then I can expose it correctly...

benaadams avatar Nov 11 '17 18:11 benaadams

Difference between LibLog's and Dapper's needs is that LibLog becomes part of your library's API. It uses a namespace transform (.pp) file to achieve that. I don't think Dapper, FluidCaching nor this has the same need.

I think you probably want a namespace transform regardless. Even if it's going to be internal only, you'd probably still want a single top level namespace in your assembly. LiteGuard.Source is internal and still has the pp namespace transform.

adamralph avatar Nov 11 '17 18:11 adamralph

I just want to be able to add a nuget package that will add the files as .cs files to the project. I'd use it everywhere!

dennisdoomen avatar Nov 11 '17 18:11 dennisdoomen

TinyIoC is another prominent example of a (fairly complex) source-only nuget package.

bitbonk avatar Nov 20 '17 10:11 bitbonk