NuGet Install Matching Pattern Version - nuget

How do you install a nuget package with a matching pattern:
For example, I want nuget to get any version matching the pattern 1.0.0* (1.1.0-rc, 1.1.0.1, etc...).
But nuget doesn't support the wildcard character, I get an error '1.1.0*' is not a valid version string
And running:
nuget install <mypackage> -Version 1.0.0 -Source <myserver>
Will only resolve 1.0.0 version and nothing else.
I actually wrote a script that queries the server for version, and picks whatever I want, but I wonder if there's a native way of doing that using just the nuget CLI.

Related

How to install no latest but highest version of npm package without specifying a version

For some reason when I do npm publish the registry does not remove latest tag from previous version and does not attach latest to newer version.
I there a way to download highest version of package without knowing exactly what the version is?
I recommend using semantic versioning if you aren't already. You can use this tool to see examples of how version spec works. Here's an example that could be included in package.json which will install the highest version of lodash in the registry:
"dependencies": {
"lodash": "x"
}
Ok, I do not know how to install highest version. But I localized a error in npm, if I publish my package when in package.json is "depraceted":false it will not change tag to latest even if I pass it as flag in publish command.

Installing Nuget Gets Dependencies Only

I have a .NET Framework 4.5 project. I'm trying to install Microsoft.NET.Test.Sdk. This should be possible as per https://www.nuget.org/packages/Microsoft.NET.Test.Sdk/
I ran the following command, but get the dependencies only. I tried installing via the Nuget Package Manager too. Finally... I see the package inside my packages.config file, but don't see it in my references. Any suggestions?
Install-Package Microsoft.NET.Test.Sdk -Version 15.7.0
I ended up using Microsoft.VisualStudio.TestTools.UnitTesting.

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?

Build a C# project fails in nuget restore package Microsoft.ApplicationInsights

I have this Azure Notification Hubs Sample
and it fails because
The 'Microsoft.ApplicationInsights 0.12.0-build17386' package requires
NuGet client version '2.8.50313' or above, but the current NuGet
version is '2.8.1.0'. The command "eval nuget restore
src/NotificationHubSample.sln" failed. Retrying, 2 of 3.
why?
It is a problem with the Microsoft.ApplicationInsights NuGet package. In its .nuspec file it has the following:
<metadata minClientVersion="2.8.50313">
NuGet will check the minClientVersion defined by a NuGet package against its product version to see if they are compatible.
The minClientVersion used in the Microsoft.ApplicationInsights NuGet package seems to be using the NuGet assembly file version and not the NuGet product version. So NuGet restore or install will always fail, at least until a newer version of NuGet is released. The latest NuGet released has a product version of 2.8.3.
Note that I am ignoring NuGet 3.0 which currently has a CTP release. So this NuGet package would work with NuGet 3.0 so maybe the creators of the Microsoft.ApplicationInsights NuGet package have only tested it with that version.
So your options are:
Report the problem to the owners of the Microsoft.ApplicationInsights NuGet package and wait for them to fix it.
Use NuGet.exe 3.0 to run the package restore with Travis.
Use a different version of the Microsoft.ApplicationInsights NuGet package which does not have this minClientVersion restriction.

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.