Using Private NuGet Feeds in AppCenter

The Problem

Recently, I was working on a Xamarin.Forms project consuming a private NuGet feed. Because the account I use to log in to Visual Studio has permissions to consume that feed, I just added the feed address to Visual Studio and I could use it without any problems.

But when I tried to build my app in in CI/CD pipeline in AppCenter, it was unable to restore the packages because it didn’t have access, and the build failed with the following error message:

Unable to find package [x]. No packages exist with this id in the source(s): nuget.org
Unable to find package [x]. No packages exist with this id in the source(s): nuget.org

The Solution

One way to tell AppCenter where the feed is located is to add a nuget.config file in the same folder where the solution (.sln) file is and to include the following content (you will need to use your own URL).

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <packageSources>
        <add key="nuget.org" value="<https://api.nuget.org/v3/index.json>" />
        <add key="MyProject" value="<https://pkgs.dev.azure.com/myorganization/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/_packaging/MyProject/nuget/v3/index.json>" />
    </packageSources>
    <activePackageSource>
        <add key="All" value="(Aggregate source)" />
    </activePackageSource>
    <packageSourceCredentials>
        <MyProject>
            <add key="Username" value="%NUGET_USER%" />
            <add key="ClearTextPassword" value="%NUGET_PASSWORD%" />
        </MyProject>
    </packageSourceCredentials>
</configuration>

The %NUGET_USER% and %NUGET_PASSWORD% are parameters that I will later replace in AppCenter.

Next, I need to go to the account on Azure DevOps and create a Personal Access Token (PAT) used as the password. That will look something like this:

Creating a Personal Access Token (PAT)
Creating a Personal Access Token (PAT)

I will need to set a name, select the organization, and set the expiration date (up to one year). For the scope, I selected custom, with Packaging Read set. After creating the PAT, I must copy and safely store the PAT somewhere, because it will not be available anymore after closing the window.

Copy the token before closing the window
Copy the token before closing the window

The final step is to set the missing user and password parameters on AppCenter. For that, I create two environment variables that will be replaced on my nuget.config file when the branch is built.

Paste the PAT in as an environment variable
Paste the PAT in as an environment variable

The NUGET_USER is not required, but I like to specify it, so I could use it in the future if I want to, instead of a PAT. The NUGET_PASSWORD is the value of our PAT.

That’s all it takes! On our next build, AppCenter will be able to access the private Nuget feed and restore all of our packages.

Thanks for reading!

Picture of Rodrigo Juarez

Rodrigo Juarez

Rodrigo Juarez has over 25 years of experience in software development, specializing in Microsoft technologies. His mission is to solve complex problems for his clients, with a focus on results. He achieves this by applying the appropriate technology and using best practices to ensure the delivery of high-quality solutions. Over the past 6 years, Rodrigo has honed his skills in back-end development and in creating mobile applications, initially using Xamarin and now transitioning to .NET MAUI. He is a Lead Mobile Developer at Trailhead Technology Partners and the co-author, along with Jesse Liberty, of the book ".NET MAUI for C# Developers"

Related Blog Posts

We hope you’ve found this to be helpful and are walking away with some new, useful insights. If you want to learn more, here are a couple of related articles that others also usually find to be interesting:

Our Gear Is Packed and We're Excited to Explore With You

Ready to come with us? 

Together, we can map your company’s software journey and start down the right trails. If you’re set to take the first step, simply fill out our contact form. We’ll be in touch quickly – and you’ll have a partner who is ready to help your company take the next step on its software journey. 

We can’t wait to hear from you! 

Main Contact

This field is for validation purposes and should be left unchanged.

Together, we can map your company’s tech journey and start down the trails. If you’re set to take the first step, simply fill out the form below. We’ll be in touch – and you’ll have a partner who cares about you and your company. 

We can’t wait to hear from you! 

Montage Portal

Montage Furniture Services provides furniture protection plans and claims processing services to a wide selection of furniture retailers and consumers.

Project Background

Montage was looking to build a new web portal for both Retailers and Consumers, which would integrate with Dynamics CRM and other legacy systems. The portal needed to be multi tenant and support branding and configuration for different Retailers. Trailhead architected the new Montage Platform, including the Portal and all of it’s back end integrations, did the UI/UX and then delivered the new system, along with enhancements to DevOps and processes.

Logistics

We’ve logged countless miles exploring the tech world. In doing so, we gained the experience that enables us to deliver your unique software and systems architecture needs. Our team of seasoned tech vets can provide you with:

Custom App and Software Development

We collaborate with you throughout the entire process because your customized tech should fit your needs, not just those of other clients.

Cloud and Mobile Applications

The modern world demands versatile technology, and this is exactly what your mobile and cloud-based apps will give you.

User Experience and Interface (UX/UI) Design

We want your end users to have optimal experiences with tech that is highly intuitive and responsive.

DevOps

This combination of Agile software development and IT operations provides you with high-quality software at reduced cost, time, and risk.

Trailhead stepped into a challenging project – building our new web architecture and redeveloping our portals at the same time the business was migrating from a legacy system to our new CRM solution. They were able to not only significantly improve our web development architecture but our development and deployment processes as well as the functionality and performance of our portals. The feedback from customers has been overwhelmingly positive. Trailhead has proven themselves to be a valuable partner.

– BOB DOERKSEN, Vice President of Technology Services
at Montage Furniture Services

Technologies Used

When you hit the trails, it is essential to bring appropriate gear. The same holds true for your digital technology needs. That’s why Trailhead builds custom solutions on trusted platforms like .NET, Angular, React, and Xamarin.

Expertise

We partner with businesses who need intuitive custom software, responsive mobile applications, and advanced cloud technologies. And our extensive experience in the tech field allows us to help you map out the right path for all your digital technology needs.

  • Project Management
  • Architecture
  • Web App Development
  • Cloud Development
  • DevOps
  • Process Improvements
  • Legacy System Integration
  • UI Design
  • Manual QA
  • Back end/API/Database development

We partner with businesses who need intuitive custom software, responsive mobile applications, and advanced cloud technologies. And our extensive experience in the tech field allows us to help you map out the right path for all your digital technology needs.

Our Gear Is Packed and We're Excited to Explore with You

Ready to come with us? 

Together, we can map your company’s tech journey and start down the trails. If you’re set to take the first step, simply fill out the contact form. We’ll be in touch – and you’ll have a partner who cares about you and your company. 

We can’t wait to hear from you! 

Thank you for reaching out.

You’ll be getting an email from our team shortly. If you need immediate assistance, please call (616) 371-1037.