Private NuGet Feed on Umbraco Cloud
A private NuGet feed is a package repository that is only accessible to a specific group of users, rather than being publicly available.
Private feeds are often used to host internal libraries or proprietary software within an organization.
NuGet is a package manager for the Microsoft development platform, including .NET. It gives you the ability to add, remove, and update libraries and tools in Visual Studio projects.
In this tutorial, we'll be covering how to set up a private NuGet feed with Umbraco Cloud.
Prerequisite
To follow along with this tutorial, you'll need the following tools:
A NuGet server such as MyGet
An Umbraco Cloud project on a standard plan or higher
Step 1: Create a NuGet package
The first part of this tutorial is to create and publish a NuGet package using Visual Studio.
To create and publish a NuGet package with Visual Studio, you will need to follow the Microsoft Documentation.
Step 2: Create your own MyGet feed
Once the first step is completed, we need to create our own MyGet feed.
To create the MyGet feed, follow the MyGet documentation.
When you create the MyGet feed, it needs to be created as private.
Step 3: Publish your NuGet package
We will publish our NuGet package to your MyGet feed in the third step.
There are two ways to do so:
Go directly to your MyGet feed and upload the NuGet package.
Follow the Microsoft Documentation.
Step 4: Add private MyGet feed on Umbraco Cloud
In the last step, we will add the private feed to our Umbraco cloud project.
To add the private feed to your Cloud project, follow the steps below:
Access the cloud Secrets Management.
Add your MyGet credentials as a Shared Secret.
Clone down your Umbraco Cloud project.
Open the project locally and build/spin up the site.
Go to your
NuGet.Configfile in the root of your project.Add the below configuration to the file:
In the above code example, you can see that we are using the Key: "MYGET_PASSWORD" that we created in the previous step. We did that by using the Cloud Secrets Management feature on Umbraco Cloud.
Push the changes to your Umbraco Cloud project.
Congratulations, you've successfully set up a private NuGet feed with Umbraco Cloud using the cloud secrets management feature!
You can now use this feed to host and manage your own internal libraries or proprietary software. If you want to learn more about NuGet and how to use it, check out the official NuGet documentation.
Hints to use Azure DevOps private feeds
For Azure DevOps feeds, it is recommended to use Personal Access Tokens (PAT). The PAT must have at a minimum the "Packaging (Read)" permission to consume packages from the feed.
PAT-tokens in Azure DevOps have an expiration date. Make sure to update your secret when you rotate your tokens.
Below is an example NuGet.Config configured for an Azure DevOps private feed:
Troubleshooting
If you experience any errors with restores on Umbraco Cloud and private NuGet feeds, there are a couple of things to consider:
Make sure passwords, API keys, or PAT-tokens are correct.
Secret values may have changed, but have not been updated in Secrets Management.
In MyGet, the username is not an email address but the account username associated with the API key.
PAT-tokens in Azure DevOps can expire - check if the value needs to be rotated. Remember to update the secret in the Cloud Portal.
PAT-tokens in Azure DevOps need to have the right kind of permission. Make sure it has the 'Read' permission on 'Packaging'.
Test the connection to a private feed locally
It is a good idea to validate the connection to a feed locally before using it on Cloud.
It is usually easier to troubleshoot if there are connection issues or problems with credentials.
You need to update the NuGet.Config file by replacing any placeholder values with valid credentials.
Do not commit the NuGet.Config file with credentials in plain text.
Run the command: dotnet restore --force --no-cache -v detailed.
If there are any errors, start by going through the troubleshooting section above.
Last updated
Was this helpful?