Can nuget create a pre-build or post-build event?

Sep 30, 2011 at 8:31 PM

I'm trying to accomplish the following:

I have a DLL that needs to be referenced in the project, along with several other DLL files that are dependencies on the first DLL, but these DLL files should just be copied to bin and not actually referenced in the project.  I'm not seeing a way to do this in nuget (it seems like it was once a spec, but isn't going to be done).  

Is there any way to do this?

If not, I'm wondering if I can have nuget create a pre-build or post-build event on my project that copies those DLL files from a folder (say "Dependencies") to the bin folder?

Thanks in advance for any help that can be provided!

Sep 30, 2011 at 9:16 PM

Take a look at the Explicit Assembly Reference section of the 1.5 release notes (

Sep 30, 2011 at 9:50 PM

This appears to be working, except that it's not copying the non-referenced files to bin.  Am I missing something?

I have several DLL files in the nuget package lib folder, and I have the following within the <metadata> section in the nuspec file:


<reference file="MyFile.dll" />


Sep 30, 2011 at 11:07 PM
Edited Sep 30, 2011 at 11:07 PM

NuGet never copies the assemblies to bin. When you reference an assembly, VS copies it to bin. When you tell NuGet not to reference an assembly, it is therefore not copied to bin.

In this case, you have to copy the file manually to bin by hooking up to the pre-build event. Check other packages (e.g. NuGetPowerTools) to see how they do it.