Could not load file or assembly 'System.Runtime, when creating nuget spec based on the assembly

118 Views Asked by At

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.

0

There are 0 best solutions below