Options for satellite assemblies

Apr 18, 2011 at 8:48 AM

I have assembly A.dll which is target of the package and must be distributed and referenced in projects depending on that package (let's call it A.nupkg). I have another assembly B.dll, on which the A.dll have dependency. B.dll must be distributed with A.dll, but must not be referenced in the project using the package (let's say it is satellite resource assembly).

How should I act in such scenario? What is the best practise?

Coordinator
Apr 18, 2011 at 5:11 PM

We don’t currently have support for this, but there’s already a bug opened on it. http://nuget.codeplex.com/workitem/263

What I’ve seen some people do is write an install.ps1 script that includes and copies those assemblies to the right place.

Phil

Apr 18, 2011 at 5:19 PM

Thanks!

Would you point me to some samples?

Coordinator
Apr 18, 2011 at 5:26 PM

http://stackoverflow.com/questions/4882762/nuget-uninstall-ps1-remove-a-project-reference

What he does is put the assemblies in lib, then removes the reference to the project. J

May 5, 2011 at 12:35 AM

This is exactly what we need as well.

We have a DAL with dependencies with the EntLib (DAAB, Logging, Exception handling) which we locally distribute as a Nuget package. Then we have the BL consuming the DAL package, which gets all the EntLib references included in the project, but it doesn't really need them, as all the data access logic is encapsulated by the DAL.

Have you considered including a new attribute in the <file> tag, like <file src="entlib.dll" reference="false" /> ?. It should be copied in the packages folder, besides the packaged dll, but not referenced in the project.

May 5, 2011 at 1:53 PM

I will also add something similar to<dependency> tag. For example, the user interface project consumes the BL package, which depends on the DAL package, which depends on the EntLib package. Now, my UI project ends up with references to BL.dll, DAL.dll and all the EntLib dlls... but it only really needs to reference BL.dll...

May 5, 2011 at 2:06 PM

Another sample from real life: 

Installing Glimpse Debugger in a web application will add references to:

  • Castle.DynamicProxy, which depends on:
    • Castle.Core, which depends on:
      • log4net
      • Nlog

Installing Combres in a web application will add references to:

  • fasterflect
  • log4net
  • dotless
  • YuiCompressor.Net
  • WebActivator

which you will probably not use in your code... so only the reference to Combres.dll should be added, and all the rest of dlls, placed besides combres.dll

May 30, 2011 at 4:26 PM

@sgisbert Even though you don't used these in code, implicit references need to be added as explicit references for them to be resolved and copied to your project's build output folder to be resolvable at runtime. Previous to NuGet, you'd have all these libs in the same directory and the compiler would find them.

Coordinator
May 31, 2011 at 5:26 PM

You could in theory take advantage of deployable assemblies (Web Projects in VS 2010 SP1 only). http://haacked.com/archive/2011/05/25/bin-deploying-asp-net-mvc-3.aspx