Issue: Assembly outside lib folder. (NuGet)
NuGet seems to be a great way to get windows developers to use your code, it makes it easy to package up an assembly to be used in another project. Seconds after uploading, I started to get developers downloading my code.
Here was a problem that I hit when I tried to package my assembly, there may be a better solution, but this worked for me.
I created a boiler-plate NuSpec file from my DLL by running
nuget spec MyAssembly.dll
I had to open the nuspec file in notepad, and edited the fairly obvious fields, like URL description, etc. Then, I went to pack the nuspec and dll together with this command:
NuGet Pack YourPackage.nuspec
However, I then got a warning:
WARNING: 1 issue(s) found with package ‘xxxx.dll’.
Issue: Assembly outside lib folder.
Description: The assembly ‘xxx.dll’ is not inside the ‘lib’ folder
and hence it won’t be added as reference when the package is installed into a project.
Solution: Move it into the ‘lib’ folder if it should be referenced.
The nupkg file was created, and I uploaded it to nuget.org, however, when I tried to download this again, using
PM> Install-Package xxxxx.dll
Installing ‘xxxxx.dll 1.0.0’.
Successfully installed ‘xxxx.dll 1.0.0’.
There was no reference added to my project, so, I couldn’t access the assembly.
So, after reading a bit, I edited my nuspec file, and added this node in the metadata
<references>
<reference file=”xxxx.dll” />
</references>
created a lib folder, and copied the dll into it. – and changed the version number
I repacked, and re-uploaded the nupkg, and when I downloaded it again, I got a reference automatically added to my test project.
And it’s all live on https://www.nuget.org/packages/OfflineAdvertsLib.dll
The correct way to fix this would be to change the files element to place the dll inside the lib directory. You should not need the references element for this.
LikeLike