:::: MENU ::::

Azure DevOps / NuGet Restore – intermittent CredentialProvider.Microsoft fails

##[error]The nuget command failed with exit code(1) and error(Problem starting the plugin 'C:\vsts-agents\smh-agent-3\_work\_tasks\NuGetCommand_333b11bd-d341-40d9-afcf-b32d5ce6f23b\2.211.0\CredentialProviderV2\plugins\netfx\CredentialProvider.Microsoft\CredentialProvider.Microsoft.exe'. Plugin 'CredentialProvider.Microsoft' failed within 6.581 seconds with exit code -1.

This annoying error was intermittent and happened mostly when several builds were running.

I’m using two steps related to NuGet:
NuGet tool installer v1
NuGet v2 – configured for restoring packages for the project

I’ve discovered this thread on Visual Studio Developer Community that suggest that it may be an issue with default NuGet timeout, which is 5 seconds.

The suggestion is to increase the default timeout, which works for me.

I’ve set within build variables two new variables and so far it works better – no more CredentialProvider.Microsoft error.

NUGET_PLUGIN_HANDSHAKE_TIMEOUT_IN_SECONDS=30
NUGET_PLUGIN_REQUEST_TIMEOUT_IN_SECONDS=30