Msbuid nuget restore failing

John David 1 Reputation point

Trying to setup an Azure App Service. Source code is in github. This .NET project builds and runs fine on local Visual Studio 2022. The App Service deployment is pretty much stock that Azure created. It grabs the code from github and then further along attempts a nuget restore. The packages that are from the default path are fine. The problem is that some packages are from and nuget restore still tries to find these in

All the search material that's coming up only has the package sources specified in Visual Studio which is great as it works on local. On the runner, I obviously don't have access to the Visual Studio to specify additional package sources. As far as I can tell adding additional package source in local Visual Studio does not change anything in the project source code/solution file so looks like that is stored in the "Visual Studio Settings" itself.

How is the runner that is doing the build expected to find the package sources/feed URLs if it's not the default

Actually, got one step closer. Found nuget.config and added the feeds there. Now trying to change the yml to look at the nuget.config

name: Build and deploy ASP app to Azure Web App  
      - main  
    runs-on: windows-latest  
      - uses: actions/checkout@v2  
      - name: Setup MSBuild path  
        uses: microsoft/setup-msbuild@v1.0.2  
      - name: Setup NuGet  
        uses: NuGet/setup-nuget@v1.0.5  
      - name: Restore NuGet packages  
        run: nuget restore -ConfigFile 'nuget.config'  

This gives an error File 'D:\a\MYAPP\nuget.config' does not exist. Any idea what syntax should be here?

I got the setup working in Azure pipelines... where the yaml is quite different so I can't really copy/paste.

- task: NuGetCommand@2  
    restoreSolution: '$(solution)'  
    feedsToUse : 'config'  
    nugetConfigPath: 'nuget.config'  


Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,038 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ryan Hill 26,241 Reputation points Microsoft Employee

    Have a look at Make sure your nuget.config file is the same directory as your project/sln or just add key referencing your nuget source in the csproj. This should allow you to utilize either the nuget restore task or msbuild running on the agent to pull the packages from the additional sources.

    Another option is using Artifacts within Azure DevOps where you could push the nuget packages your project requires and pull them from that source during the pipeline build; but I would use this as the last alternative unless I was the one creating the packages the project needed.