Nuget Package - feed (VSTS) :Exception 'System.AggregateException' thrown when trying to add source - visual-studio

I have created a new feed with in Package Release hub (VSTS), installed the credentials, then added the package source.
Now, I am using Visual Studio 2015 to install Micrososft.Aspnet.mvc to a project, however it gives the following error:
Exception 'System.AggregateException' thrown when trying to add source
'https://mysite.pkgs.visualstudio.com/DefaultCollection/_packaging/MyLogUtils/nuget/v3/index.json'.
Please verify all your online package sources are available.
I need to install NuGet packages normally, so I removed the feed from VSTS. However, the problem persists. How can this problem be resolved?

I met this issue today and fix it by following:
If you have delete the feed from VSTS, then you need to delete it from VS\Tools\Options\Nuget Package Manager\Package Sources:
If you didn't delete the feed in VSTS and want to use it, sign in with your VSTS team project account from VS upper right corner and restart VS:

This is may be an addition to the actual answer. I had to disable the check boxes as shown in below image to get the issue resolved. I think it might help to someone.

I had the same issue and I fixed issue by disabling my custom NuGet servers.
Go to Tools->Options->Nuget Package Manager and disable your custom NuGet servers

Since this is the first Page I hit with my Problem:
If you get the error for nuget.org site, increase Version number:
https://api.nuget.org/v3/index.json -> https://api.nuget.org/v4/index.json
under Tools->Options->Nuget Package Manager (see Image from #Eddie-MSFT)
V3 doesn't seem to work since today.

I also encountered that issue. I solved it by manually saving the index.json file and adding a local packaged source.

I had same issue, I resolved it by disabling its custom nuget server.

This exception might get when NuGet.Config file is readonly, for me unchecking the reaonly property of that file worked, generally, Nuget.config file exists in your project under .nuget folder.
File path project dir/.nuget/NuGet.Config

You have to ensure all your configured package source servers are available. Otherwise simply Go to Tools->Options->Nuget Package Manager and disable your custom NuGet servers.

One of the following might solve your problem.
Check and uncheck the package sources and click on update button, restart visual studio.
Uncheck all the other package source and only keep the one from nuget.org and click on update button, restart visual studio.
Once your package is install redo the changes as before.

'System.AggregateException' thrown when trying to add source 'https://devops.MyCompany.com/MC/_packaging/SharedFunctionalist/nuget/v3/index.json'. Please verify all your online package sources are available. One or more errors occurred.
Unable to load the service index for source https://devops.MyCompany.com/MC/_packaging/SharedFunctionalist/nuget/v3/index.json. Response status code does not indicate success: 401 (Unauthorized).
I got the same issue today.If you have noticed that It may asked you to enter DevOps credentials.That means it's request you to login your DevOps account.
There are two options for this type issue
1.Login with DevOps account(your Team Account) with your credentials.Then you can Install Nuget packages as usual.
2.Otherwise you have to delete existing package package source(which one is shared with team)by following below steps.
`Open Visual Studio ->Tools->Options->Nuget Package Manager-> Package Sources ->select that shared package Source and Delete it

Go to Tools->Options->Nuget Package Manager->Package Sources and uncheck the online NuGet Source named nuget.org https://api.nuget.org/v3/index.json. Also make sure your offline source is checked

I had the same problem. I resolved it by removing the checkmark from Tools/Options/Nuget Package Manager/Package Sources.

For me the package provoking the error was not showing up in the list of NuGet Sources (is it a bug?).
I had to go through the CLI (terminal) and enter
nuget sources
to get the list of Nuget sources.
Once the source causing the issue was listed I could remove it (you can also disable it)
nuget sources Remove -Name "source"
Documentation here
After that, restart Visual Studio

Related

Nuget Update failure in Visual Studio 2019

I am having a strange (new) issue with Nuget in Visual Studio 2019 (v.16.9.0).
The Solutions are all ASP.NET Web Apps (MVC). I run on a local LAN. In the Nuget Package Manager 'Allow Nuget to download packages' and 'Automatically check for missing packages during build are both selected. I am using Packages.Config for management and the source is https://api.nuget.org/v3/index.json. VS is able to communicate via the Windows Defender Firewall. The target framework is .Net 4.7.2
The first issue is when I do a package restore after deleting the packages in the folder, it shows this error: The requested operation cannot be performed on a file with a user-mapped section open.
After I do the build, the files are being created correctly, including the new/existing DLLs. These replenished/refreshed DLLs work perfectly and the program runs. The strange part, however, is that the relevant NUPKG file has zero content (which is obviously triggering the error). The message eventually disappears after completion of the DLL downloads I assume. All good so far but with zero content in the NUPKG file.
When I now try to update a package things go awry, the Error List shows:
An error occurred while trying to restore packages. The file is not a valid nupkg. File path...
Then after a full restart of VS, I get this:
An error occurred while retrieving package metadata for 'ABC.3.5.0.2' from source 'I:....\packages'. 'ABC' being the first file in the package list. It therefore appears to be failing because the relevant NUPKG has no content.
I am able to paste any file freely to the packages folder and its sub-folders, indicating that there is no lock on the files. Also VS is able to write the rest of the package structure to the folder without issue.
IMHO this must mean that something is specifically locking/blocking the NUPKG files (or deleting their content during creation perhaps?). A search reveals nothing that I can see.
I even tried creating a brand new solution. During creation, the identical error message above popped up a warning. I also tried a few other of my existing solutions and got the same result. I updated VS and then I even did a full VS reinstall to the latest version, all to no avail.
I first noticed the issue after defining dependencies during an Azure Web App deployment (the Azure deployment tool optionally allows for updates to Nuget packages). After the Nuget update failed I set the option to blank and deployed anyway, the idea being to manually update the packages later. I cannot be certain, but I think this is when I discovered the issue. Could this process have changed a VS config setting somewhere perhaps?
Before the reinstall I opened the devenv.exe.config from inside VS and changed the IPV6 setting to false. No luck, so I have changed it back. I also did a test on one of the packages, downloading the package from the Nuget site directly and replacing the VS downloaded version, but I get the same errors.
Install failed. Rolling back... Package 'System.Buffers 4.5.1' does not exist in project 'ClickAuth_Graph' Package 'System.Buffers 4.4.0' already exists in folder 'I:\My Drive\Backups\ClickAuth_Graph (01_03_21)\packages' Added package 'System.Buffers 4.4.0' to 'packages.config' Removing package 'System.Buffers 4.5.1' from folder 'I:\My Drive\Backups\ClickAuth_Graph (01_03_21)\packages' This file is not a valid nupkg. File path...\packages\System.Buffers.4.5.1.nupkg Central Directory Corrupt An attempt was made to move the file pointer before the beginning of the file. At line:1 char 1 • Update-Package System.Buffers +CategoryInfo NotSpecified: (:) [Update-Package], Exception o FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.UpdatePackageCommand
For the record I have one stale Nuget package in the portfolio. I don't use Github, but a repository was set upfront. I have not recently committed anything to Github.
Is there an expert out there that can help?
What you described is in a mess. And please try the following suggestions:
1) first clean all nuget caches or delete all cache files under C:\Users\xxx\.nuget\packages and I:\My Drive\Backups\ClickAuth_Graph (01_03_21)\packages.
I think that you have download the valid nuget packages on it and if your local exists the same name,version nuget package, it will always use the local wrong nuget package. So you have to delete them and then download the right package from the nuget package source.
2) enter Tools-->Options-->Nuget Package Manager-->Package Sources and make sure that you have enabled nuget.org package source, and if you have other own feed which you want to use, also enable it.
If not, please try to close VS, delete nuget.config under C:\Users\xxx\AppData\Roaming\NuGet. And then restart VS to re-generate it. Then, re-add your own feed if you have it.
3) run update-package -reinstall under Tools-->Nuget Package Manager--> Package Manager Console and then also delete bin and obj folder of your project.
4) you could also try to disable Azure deployment tool
Besides, if you have other solution level nuget.config, please check whether its content is suitable for your project. And if it is useless, you could remove them.

nuget dll is used by another process

I have the error from below and I'm quite out of ideas how to solve it. Tried the following until now:
Clean bin/obj/packages/packages cache
Remove manually from csproj and packages files the package and add it afterwards..still error
Update Visual Studio 2017
Reinstall Visual Studio 2017
Trace which processes are using a file with name that contains Newtonsoft
Copy the solution from another laptop where the builds works just fine
Yet, after all from above, I still get:
Error NuGet Package restore failed for project DriversApp.Android: Unable to find version '10.0.3' of package 'Newtonsoft.Json'.
C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\: Package 'Newtonsoft.Json.10.0.3' is not found on source 'C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\'.
https://api.nuget.org/v3/index.json: Error downloading 'Newtonsoft.Json.10.0.3' from 'https://api.nuget.org/v3-flatcontainer/newtonsoft.json/10.0.3/newtonsoft.json.10.0.3.nupkg'.
The process cannot access the file 'C:\Users\user\.nuget\packages\newtonsoft.json\10.0.3\lib\netstandard1.0\Newtonsoft.Json.dll' because it is being used by another process.
. Please see Error List window for detailed warnings and errors.
How to get this solved? I got really stuck on this one...
After a lot of investigation and ideas, I've solved this by uninstalling the antivirus solution as the rules added by me within my laptop were overrode by the company server policies.
As a conclusion, first check your antivirus solution, and if you are within a controlled environment, make sure your rules are not overrode by company server policies.
Thank you, #Leo Liu-MSFT for the assistance.
nuget dll is used by another process
You can try to use following troubleshooting to resolve this issue.
In Windows Explorer go to the folder where the NuGet packages are installed C:\Users\user\.nuget\packages, deleted the Newtonsoft.Json folders.
May it has something to do with the same package being referenced in multiple projects within the same solution, adding "-DisableParallelProcessing" to the nuget restore command, the final command would look like:
nuget restore "%WORKSPACE%\Solutions\App\App.sln" -DisableParallelProcessing
Excluding NuGet package files from the anti-malware products, or try to disable the antivirus. The anti-malware/antivirus products briefly locking these files during the NuGet restore operations.
Clear all referenced libraries before build the project by right click to Solution in solution explorer after click to "Clean Solution".
Most probably I was faced when there is some other error in the project (ie: project reference error etc.)
try 0: Remove all bin & obj from all project.
Try 1: Restart PC
Try 2: close vs & %temp% delete all
Try 3: Disable antivirus for the moment
Try 4: Change Debug to Release and revert back
Try 5: Clear All nuget caches
If above nothing works then shut down your pc, sit back for moments, relax and then check back.
Run this command with admin rights (net session /delete). It worked for me.

Nuget package install error -- Invalid URI: The Authority/Host could not be parsed

I'm using NuGet within Visual Studio 2017 to try to install a package on an older Web Forms project, and it is failing with the following error:
Invalid URI: The Authority/Host could not be parsed
This only happens when trying to install the package on a website that is mapped in IIS (other types of projects work fine), so the project name is http://localhost..., etc., which is what I think it's having trouble parsing. It worked fine until just a few days ago and I'm not sure what caused it to change. Here is the full message I am receiving:
Resolved actions to install package 'Newtonsoft.Json.10.0.3'
Found package 'Newtonsoft.Json 10.0.3' in 'd:\packages'.
Package 'Newtonsoft.Json.10.0.3' already exists in folder 'd:\packages'
Install failed. Rolling back...
Package 'Newtonsoft.Json.10.0.3' does not exist in project 'http://localhost:89/'
Executing nuget actions took 71.95 ms
Failed to add reference to 'Newtonsoft.Json'.
Invalid URI: The Authority/Host could not be parsed.
Another related clue is that when I open "Manage NuGet Pacakges..." on the website project, it is not showing anything as being installed, even though the packages.config file clearly exists in this project with several references defined.
My environment is as follows:
Visual Studio Professional 2107 Version 15.5.2,
Microsoft.NET Framework Version 4.7.02556,
NuGet Package Manager Version 4.5.0, and my NuGet repository is set to install in D:\packages
Does anyone have any advice on what setting I might be able to change to get this working again?
NuGet does not appear to be working for local IIS Web Site projects in VS 15.5.1 to 15.5.5 (inclusive).
The workaround is:
Close VS
(Just in case) make a backup copy of the .sln (solution file)
In a text editor open the .sln file and find the line:
Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "http://www.devsite.com", "http://www.devsite.com", "{A8837508-9BC1-482A-86EF-4B3156CAFDBE}"
Amend the second parameter and save:
Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "http://www.devsite.com", "DevWebsiteFolderName", "{A8837508-9BC1-482A-86EF-4B3156CAFDBE}"
Open your solution.
Use NuGet as you wish :-)
Optional:
Close VS
Reverse your .sln change.
Open VS
For credit and further reference:
NuGet fails for website projects hosted on local IIS
Nuget looking in wrong location for packages.config in web forms web site running on IIS
This was driving me nuts... I spent hours trying to install the Authorize.net nuget package in VS2017 and it kept throwing the same error.
I finally opened my project up in VS2015 and installed it without any issues.
Hope this helps.
Jason
Given that we haven't gotten any help from Microsoft on this, we've adopted the convention of doing something like what Barry Kaye suggested, but for the second parameter, just replacing it with a single period "."
This issue appears to be fixed in 15.6.0. Try upgrading to that version, if you can.
I encountered the same problem and I solve it this way:
Right-click on the project -> Properties -> Debug -> App URL
(The app URL was not the correct one)

Cannot add Application Insights - Failed to install package 'Microsoft.Web.Infrastructure'

I try to monitor the memory usage of my CloudService and stumbled upon Application Insights.
When I try to add it I get following error message:
right click on WebProject -> Add Application Insights Telemetrik
Insert Subscription-Data -> click Add-Button
Now the error occurs when VS tries to install 'Microsoft.ApplicationInsights.Web.2.0.0'
We are using VS2015 and Windows 10
Edit:
The fun thing is I can install Microsoft.ApplicationInsights.Webversion 2.0.0 via the nuget-console. But when I afterwards try to add the ApplicationInsights again it throws the same error and the package-manager-console displays:
The package at \Path\To\Project\packages\Microsoft.Bcl.1.0.14 failed to uninstall. Restart Visual Studio to finish the process.
Things you can try:
close VS, and start it once as admin. You may have old auto-updated extensions, etc that haven't been cleaned up until you run as admin. then close that admin VS and go back to your normal non-admin VS.
clear out your nuget packages in your solution, and then doing a full re-build to ensure that all of the current packages in your project are correctly and fully installed. when we try to install the AI nuget packages programmatically, Nuget tries to validate all of the existing packages and sometimes something goes wrong there validating things that already installed
then try re-adding AI through the tool.
if you still get the error, look in the directory shown in the error message, and comment and let me know if (a) that folder exists at all and (b) if it does exist, what's in it?
If things are still failing, you should be able to add the Microsoft.ApplicationInsights.Web nuget package manually from nuget package manager, and after that is done, right click the "ApplicationInsights.config" file that was added by the nuget package install, and you should see a "configure application insights" option that will let you pick your account, subscription, and AI resource, and that will get updated in the config file for you. If none of that works, you can send me a mail to jgardner # microsoft and i can try to track down more details for you.
Edit to add: If you get this error about Microsoft.Bcl, then your project is probably targeting .NET 4.0 and this is probably an issue we just found today. hypothetically, if you manually install microsoft.bcl into the project first, then that specific error for that specific package should go away? (we're working on verifying this specific dependency and fixing this asap).
A simple Visual Studio restart fixed the issue for me.

Error when trying to enable NuGet Package Restore in new Solution

I am getting an error when trying to enable package restore in a new solution I just created. The error in VS2012 is:
NuGet Package Manager
An error occurred while configuring the solution to restore NuGet
packages on build
Unable to read package from path 'NuGet.Build.2.7.0.npkg'.
I tried opening the solution in VS2010 to work around the problem and I am also getting an error when trying to enable package restore, but the message is different:
NuGet Package Manager
An error occurred while configuring the solution to restore NuGet
packages on build
Archive file cannot be size 0.
I tried creating a new solution, but got the same result.
I then tried doing a repair on VS2012 update 3 and rebooting. Still getting the problem.
I also scanned the folder, project, and solution file for anything NuGet or .nupkg, but there is nothing there.
So how can I get this feature working again? The last time I used it was about a week ago, and I don't remember specifically what I changed since then. I uninstalled the VS Power Tools package that I installed about a week ago, but that didn't fix the problem either.
Update
I followed the "removal" instructions here and used a project I already have as a template to enable package restore manually. However, I am still looking for a better solution because this is a feature I use frequently.
I also tried uninstalling and reinstalling NuGet from visual studio, but I still get the same issue. If memory serves correctly, there was a recent NuGet update (is there a log for VS extension installation so I can check?).
I suspect that the NuGet.Build.2.7.0.npkg file is zero bytes due to a failed download. NuGet.Build.2.7.0.npkg is the NuGet package that Visual Studio downloads in order to enable package restore for your solution.
Take a look in your cache and see if this file is zero bytes. If so then delete the file or clearing the cache and try enabling package restore again. The cache is under your profile in a directory similar to:
C:\Users\YourUsername\AppData\Local\NuGet\Cache
You can also browse to the cache from inside Visual Studio by opening the Package Manager Settings, selecting General and clicking the Browse button.
All of the previous answers, plus this one: can you run .\nuget\nuget.exe update -self if this is a solution in which package restore was previously enabled?
check whether your nuget package manager is updated one or not.
Check this from Tools-> Extensions and Updates -> Updates
Update your Nuget Package Manager and then it will work

Resources