2

I have a simple compiled library (compiled with very different TFs) that I want to provide for consumers via nugets. For this purpose I want to use nuget spec -a {libraryPath} command to create nuspec (and then nuget pack to create an actual nuget).

Apperently nuget spec command (version without arguments and with -a) doesn't generate a valid/filled nuspec file and instead always creates just an empty template.

So I have 2 questions:

  1. What's the difference between nuget spec and nuget spec -a {libraryPath}? As I understand in both of cases, the only generated output is empty nuspec file?

  2. Sometimes nuget spec -a {libraryPath} works well, but in some cases it throws error like:

    c:\test>nuget spec -a ConsoleApp1.dll
    Could not load file or assembly 'file:///c:\test\ConsoleApp1.dll' or one of its dependencies. The system cannot find the file specified.
    

where ConsoleApp1.dll is output from consoleapp project with <TargetFramework>net6.0</TargetFramework>:

or:

 c:\test>nuget spec -a SuperTest1.dll
 Could not load file or assembly 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=..' or one of its dependencies. The system cannot find the file specified.

where SuperTest.dll is output from classlibrary project (empty) with <TargetFramework>netcoreapp3.1</TargetFramework>

How to fix such errors?

UPDATE1:

sounds like I also have to create a structure like:

  lib
  --> net452 --> library1.dll
  --> netcoreapp3.1 --> library1.dll
  ... 

and then run it from the root folder:

  nuget spec -a .\lib\net452\Library.dll
  nuget pack

to be able to see the library in consumers.

5
  • 2
    net5+, netcoreapp, and netstandard can only be built using SDK style projects. These should not be packed with nuget.exe, and you shouldn't use a nuspec file either. Instead, run dotnet pack and the package will automatically be created with all the project's target frameworks. Commented Mar 10, 2024 at 16:54
  • 1
    @zivkan True. Your comment on NuGet/Home issue 12736 says it all. Commented Mar 11, 2024 at 7:57
  • Thanks @zivkan, @VonC. My goal is to provide a compiled binary to consumers via nugets. I can do it with creating a temporary project, referencing the target binary to this project and then creating a package (with dotnet pack) based on a temporary project. However it produces some noize in particular related to the fact that temporary project binary appeared in the consumer's project file (for Non-SDK projects). So I hoped I can create package that can be consumed for applications in old and modern TFs based on initial binary. Commented Mar 11, 2024 at 11:30
  • At first glance nuget spec -a does exactly this, but appererntly not in all cases. Do you have any other suggestions how to do it? Commented Mar 11, 2024 at 11:32
  • 1
    Download ProcessMonitor, it will start up running, Stop the trace, Clear the trace and filter by FileSystem only. Get ready to run the nuget command that produces The system cannot find the file specified, start ProcessMonitor and execute the command. When it fails, stop the trace and investigate ProcMon's log to see where its looking for the DLL it cant find. I suspect there's something screwy where NuGet is tricked into looking at the wrong folder, not the current folder, or GAL or it could tell you the DLL literally doesn't exist but its where its looking you need to rule out. Commented Mar 12, 2024 at 5:20

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.