Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NuGet Assembly outside lib folder

People also ask

Where do I put Nuspec files?

A NUSpec file contains package metadata and is used to create a package. A package is created from your project, which is why it would make sense to place the NUSpec file in the project folder.

Where is .NuGet folder located?

The location of the default global packages folder. The default is %userprofile%\. nuget\packages (Windows) or ~/. nuget/packages (Mac/Linux).

What is the .NuGet folder?

nuget folder is used as a cache for packages downloaded to speed up project restore and compilation. It can safely be removed. Worst case, it will have to download the packages again in the future. Follow this answer to receive notifications.


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.


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.


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).


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>

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.


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.