CodexBloom - Programming Q&A Platform

Visual Studio 2022 - implementing NuGet Package Restore for .NET 6 Project in CI/CD Pipeline

👀 Views: 0 đŸ’Ŧ Answers: 1 📅 Created: 2025-06-13
visual-studio nuget dotnet azure-devops ci-cd C#

After trying multiple solutions online, I still can't figure this out. I'm working through a tutorial and Could someone explain I'm experiencing issues with NuGet package restoration in Visual Studio 2022 when trying to build my .NET 6 project in a CI/CD pipeline... The behavior message I receive is: `NU1101: Unable to find package XYZ. No packages exist with this id in source(s): nuget.org`. I've double-checked that the package exists on nuget.org and that my `nuget.config` file is correctly configured to include the source. Here is my `nuget.config`: ```xml <?xml version="1.0" encoding="utf-8"?> <configuration> <packageSources> <add key="nuget.org" value="https://api.nuget.org/v3/index.json" /> </packageSources> </configuration> ``` Additionally, I've tried running `dotnet restore` locally, and it works without any issues. In the CI/CD pipeline, I am using Azure DevOps, and I have included the `NuGet Tool Installer` and `NuGet Command` tasks in my build pipeline. The relevant YAML configuration looks like this: ```yaml - task: NuGetToolInstaller@1 inputs: versionSpec: '5.x' - task: NuGetCommand@2 inputs: command: 'restore' restoreSolution: '**/*.sln' ``` Despite this, I still encounter the same behavior during the pipeline execution. I've also verified that there are no network restrictions on accessing nuget.org from the build agent. Could someone guide to figure out what might be going wrong? Are there specific settings I might be missing for the build pipeline to recognize and restore the packages correctly? For context: I'm using C# on Ubuntu 22.04. Any examples would be super helpful. What's the correct way to implement this? This is part of a larger service I'm building. Could this be a known issue?