Nuget install fails for pre-release package with dependencies - nuget

I have two pre-release nuget packages A.nuget and B.nuget, and B depends on A.
Install A.nuget works:
nuget.exe install A -Source E:\out\packages -OutputDirectory e:\NugetCache -Prerelease -PackageSaveMode nuspec;nupkg
Installing B.nuget fails:
nuget.exe install B -Source E:\out\packages -OutputDirectory e:\NugetCache -Prerelease -PackageSaveMode nuspec;nupkg
Unable to resolve dependency 'A.1.0.0.196-moma159241025'
I double checked and A.1.0.0.196-moma159241025 is installed under e:\NugetCache.
How can I resolve this error?

The work-around I use to solve this uses the -IgnoreDependencies switch, meaning the chosen package will install without its dependencies, regardless of whether Nuget can find them or not.
Install all packages "B" depends on (including "A")
Install package "B" using the -IgnoreDependencies switch
Install-Package A -IncludePrerelease
Install-Package SomeDependencyFromB
Install-Package SomeOtherDependencyFromB
Install-Package B -IncludePrerelease -IgnoreDependencies
https://docs.nuget.org/consume/package-manager-console-powershell-reference

Related

Download Nuget Package using Nuget.exe

Im working on an automation solution for transfering nuget packages from nuget.org to a private nuget feed. Is it possible to download nuget packages using nuget.exe? If i run the following command, it fails because it tries to install it to the directory, but i dont need to install the package i just need to download it.
.\nuget.exe install Microsoft.AspNetCore.App.Runtime.linux-x64 -source nuget.org -force
This throws the following error:
Error NU5000: Package 'Microsoft.AspNetCore.App.Runtime.linux-x64 7.0.1' has a package type 'DotnetPlatform' that is not supported by project 'C:\foo'.
I am looking for something like a -force option, so that i can just download the package without installing it.

Nuget cli with Nexus 3 OSS always getting 404

I am trying to download Nuget packages through Nexus 3 OSS Nuget proxy repository that I just created.
Nexus: OSS 3.30.1-01
NuGet Version: 5.8.1.7021
I created Nuget proxy repository:
http://127.0.0.1:8081/repository/nuget-prx/
source for this repository is https://api.nuget.org/v3/index.json
When running Nuget cli through Nexus:
C:\Nexus>nuget install jquery -source http://127.0.0.1:8081/repository/nuget-prx/
Feeds used:
http://127.0.0.1:8081/repository/nuget-prx/
Installing package 'jquery' to 'C:\Nexus'.
GET http://127.0.0.1:8081/repository/nuget-prx/FindPackagesById()?id='jquery'&semVerLevel=2.0.0
OK http://127.0.0.1:8081/repository/nuget-prx/FindPackagesById()?id='jquery'&semVerLevel=2.0.0 1138ms
Unable to find package 'jquery'
When running direct against official Nuget repository:
C:\Nexus>nuget install jquery -source https://api.nuget.org/v3/index.json
Feeds used:
https://api.nuget.org/v3/index.json
Installing package 'jquery' to 'C:\Nexus'.
GET https://api.nuget.org/v3/registration5-gz-semver2/jquery/index.json
OK https://api.nuget.org/v3/registration5-gz-semver2/jquery/index.json 519ms
Package "jquery.3.6.0" is already installed.
I already tried to switch to Nuget v2 protocol. The result was pretty similar.
What I am missing?
Any ideas will be appreciated!
Solved. Request should be: C:\Nexus>nuget install jquery -source http://127.0.0.1:8081/repository/nuget-prx/index.json

nuget.exe doesn't return all versions of specified package

I'm using the latest stable version of nuget.exe (4.3.0) and attempting to get all versions of a package.
This returns only one version:
nuget.exe list OBeautifulCode.Math.HashCodeHelper -allversions -prerelease -includedelisted -source "https://api.nuget.org/v3/index.json"
output:
OBeautifulCode.Math.HashCodeHelper 1.0.52
Same if I remove -prerelease and -includedelisted
nuget.org has multiple versions of this package (including delisted and pre-release and non-pre-release versions): OBeautifulCode.Math.HashCodeHelper
What am I doing wrong?

install-package with chocolatey never adds anything to the path environment variable

The command install-package <packagename> -providerName chocolatey never seems to add anything to the PATH envirnoment variable (Windows 10 Build 15063).
For example running
install-package docfx -providerName chocolatey
install-package wkthmltopdf -providerName chocolatey
does not do it. Where as
choco install docfx
choco install wkhtmltopdf
does it. When I run the latter the commands docfx and wkhtmltopdf are available in the command line.
So my question is: How is installation different when using the choco command directly compared to install-package and what can I do about this?
As Rob Reynolds pointed out to me on gitter that package provider is not ready for prime time:
do not use the
prototype provider for OneGet/PackageManagement - it's not official,
it's a non-fully featured prototype made by MS and it may have
security issues. See
https://github.com/chocolatey/chocolatey-oneget/issues/5#issuecomment-275404099
for details

How can I keep nuget from updating dependencies?

I'm attempting to install a nuget package which has incorrectly specified one of it's dependencies. Common.Logging.Log4Net requires log4net = 1.2.10 however the nuget package specifies log4net >= 1.2.10. Even if I manually install the older version of log4net, nuget upgrades log4net to 1.2.11 when I install Common.Logging.Log4Net. How can I get nuget to bypass dependency resolution or at least prefer installed packages of a sufficient version?
In order to bypass dependency resolution you can use the -IgnoreDependencies option:
Install-Package -IgnoreDependencies ThePackageName
You should be able to lock the package to a specific version by hand-editing the packages.config and setting the allowedVersions attribute to indicate the version span you want to allow.
<package id="Common.Logging.Log4Net" version="1.2.10"
allowedVersions="[1.2,1.2.10]" />
Note that his will however not upgrade the version of the package at all even when explicitly updating the package.
See the nuget versioning documentation for more info on versioning.