Introduction
When resolving NuGet packages from an upstream repository on Windows, users may encounter errors even though the package exists in Artifactory. A common scenario is when attempting to install a package using a command such as:
nuget install bootstrap
In such cases, the process may fail with an error such as:
Followed by 404 (Not Found) or similar messages
This issue typically occurs when a user attempts to fetch a package that has been blocked by a curation policy in the remote repository. As a result, the local NuGet.config file may become corrupted, preventing proper package resolution.
This article will guide you through identifying the root cause and resolving the issue step by step. It will also help you understand how to restore proper NuGet functionality after configuration corruption.
Resolution
Step-by-Step Instructions
Follow these steps to resolve the issue:
-
Close any running development tools
-
Delete corrupted NuGet configuration files
-
Press Windows + R to open the Run dialog
-
Type:
%appdata
-
Navigate to the NuGet folder inside the Roaming directory
-
Delete the NuGet.config file
-
Clear local NuGet configuration (second location)
-
Open Run again (Windows + R)
-
Type:
%LOCALAPPDATA%\NuGet
-
Delete the NuGet.config file from this location as well
-
Clear the local cache by running
nuget locals all -clear
-
Reconfigure NuGet source (Artifactory)
-
Go to your Artifactory remote/virtual repository
-
Open the “Set Me Up” section
-
Copy the NuGet source configuration command
Add the source again using CLI or configuration, for example:
nuget sources Add -Name Artifactory -Source https://<jfrog_url>/artifactory/api/nuget/v3/<reponame>/index.json -username user -password idtoken
nuget setapikey username:IDTOKEN -Source Artifactory
-
Retry package installation:
Based on the example above, rerun nuget install command:
nuget install bootstrap
The issue should now be resolved
Conclusion
This issue is primarily caused by a corrupted NuGet.config file, often triggered when attempting to resolve a package blocked by repository curation policies. By clearing the local configuration and re-adding the Artifactory source, you can restore proper package resolution.
If the issue persists:
-
Verify repository permissions
-
Ensure the package is not restricted by policy
-
Confirm the correct source URL and credentials