1

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.

Alex Weitz
  • 3,199
  • 4
  • 34
  • 57
  • 1
    I might be mistaken but couldn't you just use wildcard versions in your `packages.config` or `.csproj`? I'm assuming you know the id of the package you want to install. – Joakim Skoog Sep 27 '19 at 10:47
  • @JoakimSkoog haven't tried that yet, maybe it's a good idea actually if it works, for my specific solution though I was using plain nuget CLI, since I use nuget packages for storing versioned build artifacts rather than actual packages/references for .NET projects. – Alex Weitz Sep 27 '19 at 11:35
  • @JoakimSkoog can't use * in packages.config as well – Alex Weitz Oct 03 '19 at 04:30
  • You're right, you can't use the star wildcard but you can use something similar. Take a look at this: https://learn.microsoft.com/en-us/nuget/concepts/package-versioning#version-ranges-and-wildcards – Joakim Skoog Oct 03 '19 at 07:29
  • 1
    @JoakimSkoog note that the `packages.config` part doesn't provide anything usefull, you can use the wildcard * in a csproj, but that doesn't really provide a solution. So far, I'm just using a script, with: `nuget list -AllVersion -Source | findstr ` – Alex Weitz Oct 03 '19 at 10:21

0 Answers0