Download Nuget Package using Nuget.exe - nuget

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.

Related

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.

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

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 Package Manager for single project fails to load after adding RingCentralSDK

I'm on VS 2015, targeting .net 4.5.2, my "Nuget Package Manager for Visual Studio" in Extensions and Updates shows 3.4.4.1321.
I added all dependencies of RingCentralSDK package separately:
Microsoft.Bcl
Microsoft.Bcl.Async
Microsoft.Bcl.Build
Microsoft.Net.Http
Newtonsoft.Json
Portable.BouncyCastle-Signed
PubnubPCL
Then I right click on my project, pick "Manage Nuget Packages...", the tab opens, in the "Installed" subtab I can see the 7 packages.
Now, I install the RingCentralSDK package. My output is fine:
Attempting to gather dependency information for package 'RingCentralSDK.1.0.0' with respect to project 'MyProj', targeting '.NETFramework,Version=v4.5.2'
Attempting to resolve dependencies for package 'RingCentralSDK.1.0.0' with DependencyBehavior 'Lowest'
Resolving actions to install package 'RingCentralSDK.1.0.0'
Resolved actions to install package 'RingCentralSDK.1.0.0'
Adding package 'RingCentralSDK.1.0.0' to folder 'C:\code\packages'
Added package 'RingCentralSDK.1.0.0' to folder 'C:\code\packages'
Added package 'RingCentralSDK.1.0.0' to 'packages.config'
Successfully installed 'RingCentralSDK 1.0.0' to MyProj
========== Finished ==========
Now, I check again the Manage Nuget Packages for this specific project, and instead of seeing the list of packages, I get a yellow band:
Error occured Show erros in output Dismiss
And in the "Package Manager" output, the error is:
ZIP archive contains unsupported data structures.
In my packages folder, the folder "RingCentralSDK.1.0.0" seems ok, but then I don't anything about nuget packages format.
I cannot uninstall RingCentral via the package manager as it's not showing, not any other one, which is really annoying. I had an error when trying to do it via the command line. I reverted my changes (or remove the line in packages.config for my project), and the Nuget Package Manager tab works fine again. This is also affecting the "Managet Nuget Packages for Solution".
What can I do to fix this?
Fixed in RingCentralSDK 1.0.1-alpha1
It turns out that the NuGet package created on Mac is not compatible with Visual Studio NuGet GUI tool.
You can install the latest version by
Install-Package RingCentralSDK -Pre
Or if you prefer GUI:
Update:
For projects which already have 1.0.0 version installed, how to upgrade?
Today I did some testing and I came to the following conclusion:
New project will have no problem with 1.0.1 version or later
For old project which have 1.0.0 installed. You need to follow the following steps:
UnInstall RingCentralSDK 1.0.0
Close VS
Delete packages folder in your project
Delete packages folder in ~/.nuget/
Launch VS
Install RingCentralSDK 1.0.1
I need to do the above because nuget has cache. If I don't do it the problem just persists. I don't know the exactly reason but the above steps did work for me.

nuget local package source is unable to find package

I'm trying to build some packages for use within my company. I've set up a local folder on my hard drive and added it as a package source before the official nuget source. when I execute nuget list janney, my packages are found however executing install-package janney.myfirstpackage throws an error Install-Package : Unable to find package 'Janney.MyFirstPackage'.
What am I doing wrong? Is this an indication that I've messed up my packages?
In my package manager console my package source was set to nuget rather than all