1

I'm making a nuget package for my own internal use called BlobUtils. However, when I install it, my code doesn't recognize the "using" statement and it doesn't show up in the references list.

I opened up the package in NuGet Package Explorer, and it seems to look okay. I've attached a screenshot below.

I've also included a screenshot of it not working in my project. (NOTE: the using statement says "BlobUtil" because I was messing around with it, but "BlobUtils" also doesn't work.)

Thoughts?

enter image description here

enter image description here

Slothario
  • 2,830
  • 3
  • 31
  • 47
  • So did you install the package after you created it? I can't tell from your screenshot, but it seems like it isn't installed. – Michael Tracy Jun 20 '18 at 19:18
  • @MichaelTracy Yep, it's installed. – Slothario Jun 20 '18 at 19:19
  • Then there should be a packages folder in the solution with the DLL in it - you have to add that to your references. – Michael Tracy Jun 20 '18 at 19:22
  • @MichaelTracy Thanks for the tip -- it sent me in the right direction. The nuget package didn't have the right DLLs, because the "nuget pack" command didn't seem to be working. I had to create a directive in my nupack file instructing how to copy the files. Thanks for your help! It's working now. – Slothario Jun 20 '18 at 19:40

1 Answers1

0

EDIT: see imps comment below to do things better than I did.

Thanks to Michael Tracy's tip, I noticed the DLLs and the overall structure of my nupkg file was all wonky. I was getting warning messages stating "Issue: Assembly outside lib folder." What it really meant was nothing was going to the lib folder at all. I added the following lines to my nuspec file:

  <files>
      <file src="BlobUtils\bin\Debug\*.dll" target="lib" />
      <file src="BlobUtils\bin\Debug\*.pdb" target="lib" />
  </files>

That forces the intended behavior of nupack.

Slothario
  • 2,830
  • 3
  • 31
  • 47
  • 1
    I would strongly discourage, please do not target the "lib" folder directly. This will make the package incompatible for PackageReference, and makes it impossible for NuGet to test for compatibility. The best practice is to target /lib/{tfm}/*.dll Docs https://learn.microsoft.com/en-us/nuget/create-packages/supporting-multiple-target-frameworks#framework-version-folder-structure – imps Jun 21 '18 at 19:11