Let Teamcity serve multiple versions of the same nuget package - nuget

I try to have the Teamcity Nuget server provide version 1.0.0.1 and 1.0.0.2 of a package.
I built the same build configuration with different version numbers in NuGet Pack -> Version but only the version of the latest build is listed when I check with Get-Package -ListAvailable -Filter mycompany in package manager console.
I also tried with one build configuration for version 1.0.0.1 and another for 1.0.0.2, but still only the package of the latest build is listed.
How can teamcity serve multiple versions?

Try adding the -AllVersions parameter. The following seems to work with Team City but not for the main nuget.org.
Get-Package -ListAvailable -Filter mycompany -AllVersions

Related

what is the correct way of installing Google.Apis.Calendar.v3 using PowerShell

Using PowerShell v7.3.1, I am trying to install the Google.Apis.Calendar.v3 library, but I get this error.
As suggested I run Get-PackageSource
I have also installed .NET Framework 4.8.1
I have also tried Install-Module PowerShellGet -Force, which successfully installed the module, but then when I try Install-Package Google.Apis.Calendar.v3 I get the same error.
what is the correct way of installing Google.Apis.Calendar.v3 using PowerShell?
Google.Apis.Calendar.v3 is a Google package. Which is hosted on NuGet
You don't appear to have NuGet set as a package source See: register-packagesource
register-PackageSource -Name MyNuGet -Location https://www.nuget.org/api/v2 -ProviderName NuGet

How to use Powershell's Uninstall-Package to uninstall *a* specific package from *a* specific csproject

So I'm trying to automate some workflow and I'm running into issues with uninstalling/reinstalling a specific package on a specific csproject. I know this is possible with Package-Manager, but how would I achieve this within a powershell script? Here's what my script looks like so far:
# delete package folder from local feed
Remove-Item 'C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\<packageFolder>' -Recurse
# delete past package
Remove-Item '.\<package>.nupkg'
# pack new package
nuget pack '<nuspecPath>.nuspec' -NoDefaultExcludes
# push package to local feed
nuget add '.\<package>.nupkg' -Source 'C:\Program Files (x86)\Microsoft SDKs\NuGetPackages'
**# Everything below this is not currently working #**
# Remove project's outdated package
Uninstall-Package -Name '<packageName>' -Project '<pathToProject>' -Force
# Install new package to project
Install-Package -Name '<packageName>' -Project '<pathToProject>' -Source 'C:\Program Files (x86)\Microsoft SDKs\NuGetPackages' -Force
So, apparently -Project or -ProjectName are not recognized atrributes when using Uninstall-Package in powershell.. So, how do I specify powershell to uninstall a specific package on a specific csproject? Any help or insights would be much appreciated!
I tried the above code and kept getting complaints about -ProjectName attribute. I thought that this command would uninstall a nuget package from a specific project and then reinstall a new version of that package to the project.
The following answer is valid for .NET (Core) SDK-style projects, but does not work for "classic" .NET Framework projects (see this comment):
You may use the dotnet CLI to manage your projects and solutions.
Run the following command to list all packages:
dotnet list <PATH-TO-PROJECT> package
Run the following command to remove a package from the project:
dotnet remove <PATH-TO-PROJECT> package <PACKAGE-NAME>
See Install and manage NuGet packages with the dotnet CLI for more information.

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 Install Matching Pattern Version

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.

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?