Facing a strange issue in build pipeline in ADO for dot net core service.
I am trying to set a path for the packages being referred in nuget.config file. Below is nuget.config file.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<add key="repositorypath" value="..\..\Packages" />
<!--Affects projects using PackageReference only-->
<add key="globalPackagesFolder" value="..\..\Packages" />
<add key="dependencyversion" value="HighestMinor" />
</config>
<solution>
<add key="disableSourceControlIntegration" value="true" />
</solution>
<packageRestore>
<!-- Allow NuGet to download missing packages -->
<add key="enabled" value="True" />
<!-- Automatically check for missing packages during build in Visual Studio -->
<add key="automatic" value="True" />
</packageRestore>
<activePackageSource>
<add key="All" value="(Aggregate source)" />
</activePackageSource>
<packageSources>
<add key="NuGet Server" value="my private feed" />
<add key="NuGet" value="https://api.nuget.org/v3/index.json" />
</packageSources>
<disabledPackageSources />
</configuration>
After adding below line getting 401 Unauthorised.
<add key="globalPackagesFolder" value="..\..\Packages" />
Exception
Retrying 'FindPackagesByIdAsync' for source 'myfeed/nuget/v3/flat2/microsoft.extensions.dependencyinjection/index.json'.
Response status code does not indicate success: 401 (Unauthorized).
Restore failed in 8.09 sec for /home/vsts/work/1/s/Service/Test/myproject.Tests/myproject.Tests.csproj.
Below are tasks in build pipeline
pool:
vmImage: 'ubuntu-latest'
variables:
buildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller@1
- task: NuGetCommand@2
inputs:
#command: 'restore'
restoreSolution: 'Service/myservice.sln'
feedsToUse: config
nugetConfigPath: 'Service/.nuget/nuget.config'
externalFeedCredentials: 'MyPackages'
- script: dotnet build "Service/myservice.sln" --configuration $(buildConfiguration) -p:langversion=latest
displayName: 'dotnet build $(buildConfiguration)'
Build Pipeline for dot net core service fails with error 401 (Unauthorized) when provided globalPackagesFolder in nuget.config
According to the error message:
Retrying 'FindPackagesByIdAsync' for source 'myfeed/nuget/v3/xxx'. Response status code does not indicate success: 401 (Unauthorized).
We could to know it is trying to access your private nuget feed and get this 401 (Unauthorized) error. It seems you did not provide certification information in the nuget.config
file.
To resolve this issue, please try to add the certification information in your nuget.config
as following:
<packageSourceCredentials>
<NuGet Server>
<add key="Username" value="xxxxx" />
<add key="ClearTextPassword" value="Password/PAT" />
</NuGet Server>
</packageSourceCredentials>
Check this thread for some more details.
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With