powershellnugetmagick.net

Unable to find dependent package(s) (System.Runtime)


I'm having some trouble understanding what is wrong.

I'm using Windows Powershell Version: 5.1.18362.628

I expected 'Magick.NET-Q8-AnyCPU' to install.

PS C:\Users\gtamm\Source\Repos> Find-Package System.Runtime

Name                           Version          Source           Summary
----                           -------          ------           -------
System.Runtime                 4.1.2            nuget.org        Provides the fundamental primitives, classes and base classes that define commonly-used value and reference data types, events and event handlers, interfaces, attribute...


PS C:\Users\gtamm\Source\Repos> Install-Package System.Runtime

The package(s) come(s) from a package source that is not marked as trusted.
Are you sure you want to install software from 'nuget.org'?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"): Y

Name                           Version          Source           Summary
----                           -------          ------           -------
Microsoft.NETCore.Platforms    3.1.0            nuget.org        Provides runtime information required to resolve target framework, platform, and runtime specific implementations of .NETCore packages. ...
Microsoft.NETCore.Targets      3.1.0            nuget.org        Provides supporting infrastructure for portable projects: support identifiers that define framework and runtime for support targets and packages that reference the mini...
System.Runtime                 4.1.2            nuget.org        Provides the fundamental primitives, classes and base classes that define commonly-used value and reference data types, events and event handlers, interfaces, attribute...


PS C:\Users\gtamm\Source\Repos>  Install-Package -Scope AllUsers -ProviderName 'NuGet' -Name 'Magick.NET-Q8-AnyCPU'

The package(s) come(s) from a package source that is not marked as trusted.
Are you sure you want to install software from 'nuget.org'?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"): Y
Install-Package : Unable to find dependent package(s) (System.Runtime)
At line:1 char:2
+  Install-Package -Scope AllUsers -ProviderName 'NuGet' -Name 'Magick. ...
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (System.Runtime:String) [Install-Package], Exception
    + FullyQualifiedErrorId : UnableToFindDependencyPackage,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage


Solution

  • I have come across https://stackoverflow.com/a/43345128/2724376

    This indicated to me that NuGet might be updated when I had installed Powershell 7

    The solution for me is to specify the nuget v2 API instead of the now default of v3.

    if($PSVersionTable.'PSVersion'.Major -eq 5) {
        Install-Package -Name "Magick.NET-Q8-AnyCPU" -Source "https://www.nuget.org/api/v2"
    } else {
        Install-Package -ProviderName "NuGet" -Name "Magick.NET-Q8-AnyCPU"
    }