In this break/fix post, I’m going to show you how to fix a specific error that I was getting in an Azure DevOps pipeline during a dotnet publish
command that stated “Problem starting the plugin ‘CredentialProvider.Microsoft'”.
Here’s the full error message:
C:\Program Files\dotnet\sdk\5.0.201\NuGet.targets(131,5): error : Problem starting the plugin 'C:\Users\VssAdministrator\.nuget\plugins\netcore\CredentialProvider.Microsoft\CredentialProvider.Microsoft.dll'. Plugin 'CredentialProvider.Microsoft' failed within 5.256 seconds with exit code -1.
A credential problem?
It was only failing on one of three project publishes and on the NuGet portion of the publish command. My first thought was that the credentials might be incorrect. We recently had a developer leave and I thought that potentially something was set up with his credentials and was revoked. I double-checked the service connections in Azure DevOps and everything looked to be ok.
A .NET CLI version upgrade?
I then noticed that Azure DevOps was using Microsoft Build Engine version 16.9 as opposed to my local version of 16.8. I upgraded locally, and couldn’t reproduce the issue. Everything was great there.
A timeout issue? (yes)
This is when I took a closer look at the error message below.
C:\Program Files\dotnet\sdk\5.0.201\NuGet.targets(131,5): error : Problem starting the plugin 'C:\Users\VssAdministrator\.nuget\plugins\netcore\CredentialProvider.Microsoft\CredentialProvider.Microsoft.dll'. Plugin 'CredentialProvider.Microsoft' failed within 5.256 seconds with exit code -1.
As it turns out, NuGet defaults to a 5-second timeout, which very closely aligns with the 5.256 timeframe of the error. Doing some more investigating, I found you can increase this timeout by setting an environment variable. I decided to increase the timeout from 5 to 20 seconds in the azure-pipelines.yaml
and guess what? It worked!
# in your azure-pipelines.yaml
variables:
- name: NUGET.PLUGIN.HANDSHAKE.TIMEOUT.IN.SECONDS
value: 20
- name: NUGET.PLUGIN.REQUEST.TIMEOUT.IN.SECONDS
value: 20
The above tells the running pipeline to inject the following environment variables during the run:
$env:NUGET_PLUGIN_HANDSHAKE_TIMEOUT_IN_SECONDS=20
$env:NUGET_PLUGIN_REQUEST_TIMEOUT_IN_SECONDS=20
Maybe it was the Azure DevOps upgrade of the build tools to 16.9 made Azure Pipelines get just slow enough to push it past the 5-second timeout for the CredentialProvider.Microsoft plugin.
We’re also connecting to 3 external feeds during this project, so it’s more than the average project that may only connect to the main NuGet feed.
Hopefully, this gives you some insight into the problem and a quick solution to save you a few hours. On to the next fire!