I have setup a new team project on VSTS for our development team and am using the Package-Management extension for publishing our NuGet packages.
I have also enabled the public nuget.org feed as an upstream source for our internal package feed.
As recommended here & here I have unchecked nuget.org as a package source within Visual Studio.
Now I expect the search to find packages published to this feed first
and if not then fetch it from the upstream.
But this is not the case and am unable to add packages from nuget.org
unless I enable nuget.org as a package source from within Visual Studio.
Packages from nuget.org (that where added by enabling nuget.org) start appearing in my private feed once I publish packages to my feed.(even after I uncheck nuget.org source)
But I can't consume new packages directly from the upstream without enabling nuget.org as a source.
Have I misunderstood this is this supposed to be a build machine configuration rather than a developer machine configuration?
You missed this section in the documentation:
If you're using upstream sources, package-versions in the upstream
source that haven't yet been saved into your feed (by using them at
least once) won't appear in the NuGet Package Manager search. To
install these packages:
On the upstream source (e.g. nuget.org), copy the Install-Package
command.
In Visual Studio, open the Package Manager Console from Tools -> NuGet Package Manager.
Paste the Install-Package command into the Package Manager Console and run it.
In Visual Studio (I'm using VS 2019), updated versions of packages from upstream should appear in the dropdowns automatically, except in the following case:
If PackageA depends on PacakageB, but PackageB is not explicitly installed (i.e. you didn't add it explicitly in your project's Manage NuGet Packages page), then PackageB will be frozen at the last version that was implicitly installed.
Example:
On your Manage NuGet Packages page you install System.Text.Json version 5.0.0. This causes your app to be implicitly dependent on System.Text.Encodings.Web 5.0.0.
Some time later, you upgrade System.Text.Json to version 5.0.1. There is also a new version 5.0.1 of System.Text.Encodings.Web, but since System.Text.Json 5.0.1 depends on System.Text.Encodings.Web >= 5.0.0, the version already in your feed satisfies the implicit dependency. Your feed will keep version 5.0.0.
Sometime later you need to update to System.Text.Encodings.Web version 5.0.1. You search for System.Text.Encodings.Web on the NuGet package page, but notice that version 5.0.0 is the only version available!
Solution
4.1. Click Install on version 5.0.0. This will make the package an explicit dependency.
4.2. Now, on the updates tab, you will see 5.0.1 appear as an update option.
As you found, you do should also select nuget.org package source (both select you VSTS feed and nuget.org as package sources).
If you un-select nuget.org package source in VS, that means packages from nuget.org won’t be available.
For the purpose to search a package from VSTS feed first, and then search in nuget.org, you can achieve it by filtering packages from different package sources:
To search a package (such as NUnit package) from VSTS feed (the name is new for below example) first:
Sepecifying Package source as new, if there shows the related package(s) in browse list, then you can use the package(s) from VSTS feed. If there has no packages list, that means VSTS feed does not have related packages, then you can serarch from nuget.org as below step.
To serach the package (NUnit) from nuget.org, you just need to change the package source as nuget.org, then VS will list related packages which store in https://api.nuget.org/v3/index.json.
Related
I have a problem updating the Nuget packages. I had to install my Visual Studio in a new environment and new is also Azure DevOps. Previously we had the TFS.
Meanwhile I have some packages on the Azure DevOps that I need for my Solution. In addition, packages from Nuget.org are still needed.
In my solution older versions of the Nuget packages are included. Some packages I can't update for some reasons.
Now I have a Nuget package that needs to be updated and here comes my problem. When I go to Tools --> Manage Nuget Package for Solutions... and click on Install, it brings me in the Preview Changes overview all packages that have an older version and wants to update all of them.
Where can I set it or what do I have to do, so that only the one package is updated, which I have selected? In my old environment it works normally.
Thanks.
Cheers
If you want to update one package for all the projects under the solution, you should right-click on the solution-->Manage Nuget Packages for Solution
This will update the package of all selected projects to one same version.
You could also right-click on the project-->Manage nuget packages to update the package one by one. It is definitely not as flexible as the above one .
Let's say I have a nuget package in my Nexus repository called MyPackage.1.0.0. I also have a solution in Visual Studio that has MyPackage.1.0.0 installed. If I make a change to my nuget package in Nexus but I don't change the version number, what happens in Visual Studio? Will Visual Studio know that the installed package is outdated? Will it automatically download the new version next time the solution is built?
No, Visual Studio will not detect this and will not use the updated package. Also, if you are using package reference nuget package management format, the package once installed gets extracted to the global packages folder. If you now try to install this package in a completely different project, nuget first looks in this global packages folder and if it finds it which it will, it will use it and not go to package sources to retrieve it again.
You can clear the local nuget caches by calling
nuget locals all -clear
from the command line.
After that, all packages will be downloaded again. This may be acceptable during development (i.e. if you need to tweak your package until it works), but clearly is not an option if others are using the same version already.
My scenario is this:
Use nuget install without version to get the latest version of a package
Publish a new version of the package
Check with nuget list that the new version is indeed published
Run nuget install again.
What I noticed is that nuget install does not fetch the new version right away. It takes about an hour to see it.
So how does it work exactly?
Nuget caches all made requests in the http-cache (see "nuget locals" in the docs for reference). Objects (aka queries and their result) in this cache have an expiration of about 30minutes to 1 hour depending on the version of nuget.exe.
Use nuget locals http-cache -clear to clear this cache, then nuget should fetch the new versions without having to wait
I know there's an answer for this question from 2016 but it's not working today. I have VS2013 with the latest CU installed.
My Nuget package source settings:
I want to install the nu-get package "Serilog.Sinks.MSSqlServer". First, I ensure nuget is up to date by navigating to the ".nuget" folder of the solution's folder and running "nuget update -self":
Unfortunately, I still get the error when trying to add the package:
If I try to update nuget from the "Extensions and Updates" page of VS then I get a 403 error as shown below:
The 403 does suggest a proxy issue but other packages can be installed to the same dev box ok. I just installed "Apache log4net" from the Manage NuGet Packages window - no problem
Any ideas of a work-around for this please?
This might be related to the fact that you now (with the new NuGet CLI tool version) need to use the new NuGet API.
from nuget.org
NuGet feed v3 (VS 2015 and later / NuGet v3.x and above): https://api.nuget.org/v3/index.json
NuGet feed v2 (VS 2013 and earlier / NuGet 2.x): https://www.nuget.org/api/v2
You can check (and edit) your NuGet Package Sources under Tools, Options, NuGet Package Manager, Package Sources.
#Rob Bowman, in response to your comment and looking at the screenshot of your Available package sources, try edit your default nuget.org to https://api.nuget.org/v3/index.json or add a new source and make sure they're both enabled. Maybe that'll do the trick.
Update: maybe manually updating the NuGet Package Manager (since updating it through Extensions and Updates is not working) solves the problem. NuGet Package Manager for Visual Studio 2013.
Going to Visual Studio menu Help, About should display the currently installed version of this extension (and others).
To fix this I had to:
logon to a PC not connected to the corporate proxy
download the latest version of the nuget package manager (VSIX) for VS2013 from https://marketplace.visualstudio.com/items?itemName=NuGetTeam.NuGetPackageManagerforVisualStudio2013
copy the VSIX to my corporate dev VM and install
I am attempting to manage multiple versions of package in a on-premises NuGet repository. My version numbering did not start out with sufficient care; in one case a new package has a larger build number than the previous. I want developers to be able to choose the correct version.
This post mentions how to list all versions with the Package Manager Console.
Is there a way to choose a version or list all versions with the NuGet Package Manager, like you can with the Package Manager Console?