nuget package restore

If you are using private feed then make sure you have installed this;

https://github.com/Microsoft/artifacts-credprovider

I ran this command in powershell (admin mode);

iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/microsoft/artifacts-credprovider/master/helpers/installcredprovider.ps1'))

I have to run this command to restore packages;

dotnet restore –interactive

This command will open up a window and ask you to login to Microsoft website with a code. Login to https://microsoft.com/devicelogin and enter the code. This will do some sort of IDE verification. Close VS and reopen. You should be able to see all of your custom and nuget packages restored.

I found this alternative today;

dotnet restore projectName

This will restore the packages.

From within Visual Studio you can use the Package Manager Console to also update the packages. This has the benefit that any PowerShell scripts will be run as part of the update where as using NuGet.exe will not run them. The following command will update all packages in every project to the latest version available from nuget.org.

Update-Package

You can also restrict this down to one project.

Update-Package -Project YourProjectName

If you want to reinstall the packages to the same versions as were previously installed then you can use the -reinstall argument with Update-Package command.

Update-Package -reinstall

You can also restrict this down to one project.

Update-Package -reinstall -Project YourProjectName

The -reinstall option will first uninstall and then install the package back again into a project.

Close and restart VS. Hopefully this will restore the packages.

Another problem might be yellow triangle icon next to package references. To solve this, make sure you are targeting same framework in multiple projects. Here is a discussion about this;

https://stackoverflow.com/questions/20186216/why-do-i-get-a-warning-icon-when-i-add-a-reference-to-an-mef-plugin-project

Resources

https://github.com/dotnet/sdk/issues/10189

https://stackoverflow.com/questions/6876732/how-do-i-get-nuget-to-install-update-all-the-packages-in-the-packages-config

FavoriteLoadingAdd to favorites
Spread the love

Author: Shahzad Khan

Software developer / Architect