dwilli
dwilli

Reputation: 641

Missing NuGet packages in Azure Pipeline

I am running my Azure pipeline to build a .net solution and create an artifact for deployment. I have included a NuGet Restore step before the Build Solution step, but I get multiple instances of the error:

This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.

There are also these messages about some packages

Metadata file '....\packages\dllName' could not be found

I've tried deleting the PackageReference elements in the project files, removing the PackageReference process altogether, updating the NuGet version to the latest, checking the NuGet.Config file, the NuGet sources, and can't find a resolution to this problem.

Upvotes: 0

Views: 169

Answers (1)

dwilli
dwilli

Reputation: 641

After hours and hours of troubleshooting, the answer turned out to be that the solution file name in the 'NuGet Restore' task was incorrect and nothing was logged saying that the solution was not found. The 'NuGet Restore' command was running and finishing, but not putting any packages into the package folder. The output of the 'NuGet Restore' command was very simple and didn't show any activity:

C:\Windows\system32\chcp.com 65001   
Active code page: 65001  
Detected NuGet version 6.11.0.119 /   
6.11.0+324d7272b8526a3826ef1f12fa6fc3a362b5bb79.324d7272b8526a3826ef1f12fa6fc3a362b5bb79  
Finishing: NuGet restore  

After changing the path to the solution in the 'NuGet Restore' task and the build task, the solution built successfully. The output of the 'NuGet Restore' task should look more like this:

C:\Windows\system32\chcp.com 65001
Active code page: 65001
Detected NuGet version 6.11.0.119 / 6.11.0+324d7272b8526a3826ef1f12fa6fc3a362b5bb79.324d7272b8526a3826ef1f12fa6fc3a362b5bb79
C:\hostedtoolcache\windows\NuGet\6.11.0\x64\nuget.exe restore D:\a\1\s\Solutions\Portals\PCPC-ADX8Portal.sln -PackagesDirectory D:\a\1\s\packages -Verbosity Detailed -NonInteractive -ConfigFile D:\a\1\s\Solutions\Portals\.nuget\NuGet.Config
NuGet Version: 6.11.0.119
MSBuild auto-detection: using msbuild version '17.10.4.21802' from 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\bin'. Use option -MSBuildVersion to force nuget to use a specific version of MSBuild.
MSBuild P2P timeout [ms]: 120000
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\bin\msbuild.exe "C:\Users\VssAdministrator\AppData\Local\Temp\NuGetScratch\lzizzmep.ojf.nugetinputs.targets" /t:GenerateRestoreGraphFile /nologo /nr:false /v:q /p:NuGetPropsFile="C:\Users\VssAdministrator\AppData\Local\Temp\NuGetScratch\x4bmft5s.yrp.nugetrestore.props" /p:NuGetRestoreTargets="C:\Users\VssAdministrator\AppData\Local\Temp\NuGetScratch\xecznazl.lha.nugetrestore.targets" /p:RestoreUseCustomAfterTargets="True" /p:DisableCheckingDuplicateNuGetItems="True" /p:RestoreTaskAssemblyFile="C:\hostedtoolcache\windows\NuGet\6.11.0\x64\nuget.exe" /p:RestoreSolutionDirectory="D:\a\1\s\Solutions\Portals\\" /p:RestoreConfigFile="D:\a\1\s\Solutions\Portals\.nuget\NuGet.Config" /p:RestorePackagesPath="D:\a\1\s\packages" /p:SolutionDir="D:\a\1\s\Solutions\Portals\\" /p:SolutionName="PCPC-ADX8Portal"

Restoring NuGet package AntiXSS.4.3.0.
Restoring NuGet package Antlr.3.5.0.2.
  GET https://api.nuget.org/v3-flatcontainer/antixss/4.3.0/antixss.4.3.0.nupkg
  GET https://api.nuget.org/v3-flatcontainer/antlr/3.5.0.2/antlr.3.5.0.2.nupkg
  OK https://api.nuget.org/v3-flatcontainer/antlr/3.5.0.2/antlr.3.5.0.2.nupkg 19ms
Acquiring lock for the installation of Antlr 3.5.0.2
Acquired lock for the installation of Antlr 3.5.0.2
  OK https://api.nuget.org/v3-flatcontainer/antixss/4.3.0/antixss.4.3.0.nupkg 58ms
Acquiring lock for the installation of AntiXSS 4.3.0
Acquired lock for the installation of AntiXSS 4.3.0
PackageSignatureVerificationLog: PackageIdentity: Antlr.3.5.0.2 Source: https://api.nuget.org/v3/index.json PackageSignatureValidity: True
PackageSignatureVerificationLog: PackageIdentity: AntiXSS.4.3.0 Source: https://api.nuget.org/v3/index.json PackageSignatureValidity: True
Installed Antlr 3.5.0.2 from https://api.nuget.org/v3/index.json to C:\Users\VssAdministrator\.nuget\packages\antlr\3.5.0.2 with content hash CSfrVuDVMx3OrQhT84zed+tOdM1clljyRLWWlQM22fJsmG836RVDGQlE6tzysXh8X8p9UjkHbLr6OqEIVhtdEA==.
Adding package 'Antlr.3.5.0.2' to folder 'D:\a\1\s\packages'
Added package 'Antlr.3.5.0.2' to folder 'D:\a\1\s\packages'

Upvotes: 0

Related Questions