Do nuget feeds follow a defined standard? - nuget

My understanding is that the nuget CLI and visual studio itself work not only with the offical nuget.org feed but with other feeds from third party sites like myget.
Does this mean that the feeds themselves follow a defined standard, so the tools can work with any feeds?
If so where can I find this standard?
I am also confused about the difference between the v2 and v3 nuget.org feeds.
Update
I now understand that there are two versions of the official nuget feeds, v2 which is OData based and v3 which is a rest api. I also understand that the nuget cli and visual studio are able to talk to both.
What I still don't understand is that if you look at this post https://docs.nuget.org/create/hosting-your-own-nuget-feeds, it states
There are several third-party NuGet Servers available that make remote
private feeds easy to configure and set-up, including Visual Studio
Team Services, MyGet, Inedo's ProGet, JFrog's Artifactory, NuGet
Server, and Sonatype's Nexus. See An Overview of the NuGet Ecosystem
to learn more about these options.
For both the nuget cli and visual studio to be able to work with all these various thirdparty feeds, surely there must be some underlying common standard feed format. Are they all use the same OData format as v2 for instance? This is the crux of my question.

NuGet v2 provides an OData feed.
NuGet v3 provides a restful API uses a few different protocols, one of which I believe is based on JSON-LD.
There is some information in the Building NuGet 3.x post about this.
There is also some more information about the NuGet v3 API in another StackOverflow post
What NuGet API third party servers support is up to the third party server. VSTS for example supports both NuGet v2 and NuGet v3 APIs each of which have a different url. Team City for example implements the NuGet v1 API. ProGet at the time of writing supports NuGet v2.
The NuGet client itself hides these differences from you unless you use some of the lower level classes. The NuGet client itself has a simple check that if the url ends with index.json then it is a NuGet v3 feed and uses a different set of classes to connect to the server. Otherwise it uses a NuGet v2 set of classes to connect to the server.

The feed organization is based on a set of APIs, clients that manipulate the feed (e.g.,
nuget.exe) use these API to manage the feed.
Here is a description for a NuGet v3 feed: https://learn.microsoft.com/en-us/nuget/api/overview

Related

Cannot add NuGet feed to Azure Dev Ops artifacts

I have a NuGet feed for another source of packages for my project that I'd like to add to the Azure Dev Ops artifacts section as an upstream source, joining the standard NuGet feed. However, despite what the documentation says (https://learn.microsoft.com/en-us/azure/devops/artifacts/how-to/set-up-upstream-sources?view=azure-devops), the only custom option I see is for "custom NPN registry" with a note saying npm is the only package type that supports custom public upstream sources.
I added my feed anyway but it's not findable in Visual Studio's package manager, though I was able to add something from the standard NuGet feed. Is there a setting I'm missing to enable custom NuGet feeds to be added in, or are the docs incorrect here?
I believe you are misreading the documentation.
Custom public upstream sources are only supported with npm registries.
Ref: https://learn.microsoft.com/en-us/azure/devops/artifacts/how-to/set-up-upstream-sources?view=azure-devops#enable-upstream-sources-in-an-existing-feed
If you want to use a single feed for everything, you'll have to implement a bit of a hacky workaround.
The workaround, as unfortunate as it may be, would be to use a scheduled pipeline to synchronize the external feed with your Azure DevOps feed.

Can I publish symbols to VSTS?

I'm currently publishing some NuGets to my VSTS feed. Is there support for VSTS acting as a Symbol Server as well so I can publish my symbol packages?
You can publish your symbols to a file share. There is not presently support for using VSTS itself as a symbol server.
It is now possible to use VSTS as a symbol server
I've also written a blog post on how to setup a symbol-server using a VSTS build definition where the symbols are published on a file share. It's actually more as a step-by-step guide on how to publish and expose them via IIS
Checkout Source Link. It is becoming a new standard or at least recommended way.
SourceLink is a language- and source-control agnostic system for providing first-class source debugging experiences for binaries. The goal of the project is to enable anyone building NuGet libraries to provide source debugging for their users with almost no effort. Microsoft libraries, such as .NET Core and Roslyn have enabled SourceLink. SourceLink is supported by Microsoft.
In a case of VSTS Git repository and .Net Core project
Add nuget reference of Microsoft.SourceLink.Vsts.Git to your project - the one which will be dotnet pack later (as of now in preview - make sure you tick "Include prereleases" in VS Nuget Manager)
Add <AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder> into PropertyGroup where the TargetFramework element is.
Add .NET Core task with command pack
The nuget package will now contain PDB files so you clients can easily debug your library.

Does Visual Studio 2015 support Nuget v1 feeds

I have a v1 Nuget feed from Team City.
I have installed VS 2015.
I am trying to install and existing package and I receive on the find packages the following error
is not a valid NuGet v2 service response
Does VS2015 no longer support V1 feeds? or is there a configuration I can change.
I've got a similar issue with the TeamCity nuget feed.
To answer your first question, yes, I believe that VS2015 still supports Nuget API V1.
Here's what I think I know so far:
TeamCity can use either v1 or v2 of the Nuget API.
FindPackagesById is implemented in Nuget API v2 not v1 (you can force TeamCity to use v2 by adding a line teamcity.nuget.api.version=v2 to the internal.properties file in the TeamCity Data directory.
To find out what version you are using you can browse the $metadata endpoint on your server (e.g. http://mybuildmachine.com/httpAuth/app/nuget/v1/FeedService.svc/$metadata). The presence of the FindPackagesById method will show you are using v2. The version number in the url doesn't change. Yes, it's confusing.
TeamCity returns 204 No Content when FindPackagesById returns no packages. Nuget.org returns no results, but wrapped in an XML document.
The source below, in the ASP.NET source is where everything goes wrong. If the XML document from the response cannot be parsed then it just falls over and dies.
https://github.com/aspnet/dnx/blob/37575f3197c0b65d42e3a1db240d636aeab5a1e6/src/Microsoft.Framework.PackageManager/Restore/NuGet/NuGetv2Feed.cs#L230
I couldn't find copies of the Nuget spec to determine what's considered a valid response to FindPackagesById but if a 204 response is a violation of the spec then this could be a TeamCity bug.
My current workaround when using multiple packages sources is just to temporarily disable irrelevant sources when installing specific packages.

Can I use my OctopusDeploy built-in Package Repository in Manage NuGet Packages?

I have a working Octopus Deploy server which has a library of packages I built.
I have an assembly which depends on one of the assemblies which I have deployed in Octopus Deploy and which is currently in that repository. I tried adding it as a package source in NuGet Package Manager, with my repository's URL (something like:
http://myoctoserver/app#/library
).
It will not populate the list Manage NuGet Packages of Visual Studio 2013, although the Microsoft and .NET and the nugget.org will populate.
Documentation doesn't appear to address this at OctopusDeploy.com. Is this something that can be done, or does my organization need to make an external NuGet feed?
Octopus Server provides a write-only repository and it can't be consumed by other NuGet clients.
There are many options available to you depending on your budget / hardware
ProGet
MyGet
NuGet.Lucene
NuGet Gallery
Octopus built in package repository is not mean't to be consumed by others.
The nuget packages there, are built specifically for Octopus. They have different structure. These packages are meant to be unpacked directly to a specific location, and run by either Windows service or IIS.
Also, from docs:
It is important to understand that the Octopus server provides a
write-only repository; intended for hosting application packages only
. Packages that are pushed to the Octopus server can't be consumed by
other NuGet clients like Visual Studio. If you need a NuGet feed for
sharing libraries between your development projects, a separate NuGet
repository is required.
http://docs.octopusdeploy.com/display/OD/Package+repositories
We host internal nuget server ourselves, which works very nicely.

Self-Hosting NuGet

I have been looking at self hosting NuGet, having a hard time understanding how to set it up and how it would help support our development process.
Does anyone have any recommendations as to which to use, how to set it up?
Or should I just use a hosted service?
After looking around at various solutions--self-hosted and hosted service--we chose to go with ProGet.
ProGet Summary
ProGet has a standard "free" license and nominal licensing fees (single year and perpetual) for the enterprise version. We currently use the standard "free" version and have no real complaints. You can create as many feeds as you want, add as many users as you want, etc. (We created "Testing", "Staging", and "Production" feeds to be part of our quality assurance process.) The only real limit in the free version is the inability to filter external feeds for specific packages you want included in your ProGet feeds. This filtering feature is managed with "connectors". With the enterprise version--when you create a feed--you can optionally add a "connector" to pull in packages from other feeds (external or internal).
ProGet With Nuget Package Management and Creation
The steps for creating a nuget package itself I'll leave to David Ebbo's popular blog post, http://blog.davidebbo.com/2011/04/easy-way-to-publish-nuget-packages-with.html. However, know that for uploading packages you can upload via the ProGet packages administration web UI, command-line nuget.exe, or the Nuget Package Explorer.
ProGet Installation, Configuration, and Activation
Installing, configuring and activating ProGet was the least intuitive part. It can install backed by a regular SQL Server database or a SQL Server Express db. Furthermore, it can also be a self-hosted app or run under IIS. If you need to perform offline activation or want to request different license keys go to my.inedo.com and create an account and you can do everything from there.
Proget Quality Control & CI
CI with TeamCity is something we are going to need so we are looking at creating a nuget package build process using TeamCity's Nuget server. There's a how-to for creating the packages I'll post in a comment. The next step would be to automatically publish the TeamCity-created nuget packages over to the appropriate ProGet feeds (ie. "Testing", "Staging", "Production") perhaps utilizing command-line Nuget with an API key.
Further Information
We looked at MyGet as a hosted service but it seemed to trip up on simple scenarios like adding another contributor/user. It also jumped quite a bit in price when needing more than just two contributor accounts. Whereas with ProGet you get unlimited user accounts with the free version alone.
One more side note: For publishing OSS type projects/packages, I'd take a look at Chocolatey as a solution.
Another option for self hosting is using the NuGet.Server package and creating an IIS website to host it on your internal network, although it won't scale very well if you plan to publish more than a handful of packages.
I've created a fork of NuGet.Server that uses a Lucene.Net index to fix these performance issues. Downloads are available from https://github.com/themotleyfool/Klondike/releases.
To keep this thread up-to-date, Visual Studio Team Services also has a package manager in preview. See the marketplace: Package Management
You can create an empty Asp.Net Web Application and install Nuget.Server from Nuget Gallery. This is a free option of self hosting your own Nuget packages on IIS. Check the documentation