NuGet Assembly outside lib folder

NugetNuget Package

Nuget Problem Overview


I'm going to bang out a couple of questions here...first, with NuGet is it possible to create a package from a few DLLs? There is no visual studio project, just the command line and a couple of pre-compiled DLL files.

Second, assuming that is possible, why do I continuously get the "Assembly outside of the lib folder" warning? I've tried everything I can think of to get associated assemblies to add themselves as references inside of the NuGet package.

My file structure looks like this

 Root
   - File1.dll
   - lib
     - File2.dll
     - File3.dll

When I tell NuGet to pack it using a .nuspec like this

<?xml version="1.0"?>
<package >
  <metadata>
    <id>File1.dll</id>
    <version>1.0.0</version>
    <authors>thisguy</authors>
    <owners>thisguysmom</owners>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>This is some library</description>
    <releaseNotes>Porting to NuGet</releaseNotes>
    <copyright>Copyright 2012</copyright>
    <references>
	  <reference file="File2.dll" />	  
	  <reference file="File3.dll" />
	</references>
  </metadata>
</package>

I receive that warning. From what I'm reading, I shouldn't even have to define the references node in any of my projects, as the lib folder items should automatically be added as references?

Does anyone out there understand this NuGet mess?

Nuget Solutions


Solution 1 - Nuget

I just ran into this problem. Nuget is expecting a structure that looks like:

root
  - lib
    - net40
      - File1.dll
      - File2.dll
      - File3.dll

net40 or net20 or net45 as appropriate to your .net version.

run

nuget pack yourlibrary.nuspec

to package it up.

That will pack up the dir wholesale and put it in the nupkg. The error messages will disappear at that point.

Solution 2 - Nuget

Any dll that you want referenced should be under the lib folder. The warning is because file1.dll is outside lib and will be ignored during package installation. (Other special folder are "content" and "tools")

I'd used this structure :

Root
  - lib
    - File1.dll
    - File2.dll
    - File3.dll

See : http://docs.nuget.org/docs/creating-packages/creating-and-publishing-a-package#Package_Conventions for additional details.

Solution 3 - Nuget

With the version of NuGet that is current as of this post (and I assume later versions as well), you can use the .csproj file, in tandem with the .nuspec file to create the package. What we did was make a .nuspec file (using nuget spec and then customizing it) and include it in the project.

With the customized .nuspec file, we used the command:

nuget pack sample.csproj -IncludeReferencedProjects

At that point it built the .nupkg and did not emit issues. The .nupkg file showed up in the normal output folder (in my default case, bin\debug).

Solution 4 - Nuget

You may add references to another dll by adding below inside tag in nuspec file

<package>
   <metadata>
      ...
</metadata>
<files>
 <file src="..\ReferencedFolder\*.*" target="lib\net40\" />
</files>
</package>

Solution 5 - Nuget

Alexandre is referring to the "lib" folder that gets created when you create a NuGet package. You can open the .nupkg just like you would any zip file. In there, you will see a lib\netXX folder where XX is the version of the .NET framework you're targeting. So when you're packing your NuGet file, make sure File1.dll is inside the lib folder.

Solution 6 - Nuget

I used Prof Von Lemongargle' solution, and for me was a great solution. Important:

  1. Include spec file (with right-click-> Include in project) in the project
  2. Give to spec file THE SAME FILENAME of your project (myproject.csproj, myproject.nuspec)

This work perfectly in Visual Studio 2012.

Solution 7 - Nuget

They get into the "lib" folder by being included in your bin\debug or bin\release folder in .NET. So you need to get the project compile to copy local on the external DLLs so it includes them in the bin folder on compile.

Solution 8 - Nuget

If dependencies or libraries have been changed, old files affect the packaging operation.

  1. Remove obj and bin folders from project.
  2. Run dotnet restore
  3. Run nuget pack yournuspecfile.nuspec -properties Configuration=Release -IncludeReferencedProjects or your command whatever.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionfarinaView Question on Stackoverflow
Solution 1 - NugetJason WallView Answer on Stackoverflow
Solution 2 - NugetAlexandre DionView Answer on Stackoverflow
Solution 3 - NugetProf Von LemongargleView Answer on Stackoverflow
Solution 4 - NugetMadhu RanjanView Answer on Stackoverflow
Solution 5 - NugetAdam SView Answer on Stackoverflow
Solution 6 - Nugetuser2408082View Answer on Stackoverflow
Solution 7 - Nugetuser3683706View Answer on Stackoverflow
Solution 8 - NugetHayrullah CansuView Answer on Stackoverflow