Unable to install nuget package due to bad request - c#

Today I want to install Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation package.
But it turns out I get bad request for
https://api.nuget.org/v3-flatcontainer/microsoft.aspnetcore.mvc.razor.runtimecompilation/5.0.10/microsoft.aspnetcore.mvc.razor.runtimecompilation.5.0.10.nupkg
And it said
"The feed 'nuget.org [https://api.nuget.org/v3/index.json]' lists package 'Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation.5.0.10' but multiple attempts to download the nupkg have failed. The feed is either invalid or required packages were removed while the current operation was in progress. Verify the package exists on the feed and try again.
Unable to find package 'Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation.5.0.10'."
I have checked that package source is from
https://api.nuget.org/v3/index.json
Does anyone know how to fix this problem?

You might want to look at the answer here.
Just like Leo Liu-MSFT said:
Clean the entire NuGet package cache by the command:
nuget locals all -clear
Close all Visual Studio instances, delete the nuget.config file in the location:
C:\Users\leoliu\AppData\Roaming\NuGet\NuGet.Config
and then reopen Visual Studio to restore NuGet packages.
Check if there is a firewall policy or other proxy settings that is blocking the NuGet installation package.

Related

The package at 'Path' failed to uninstall

So I am using Visual Studio 2022 on Windows 11. I am trying to install a nuget package.
I get the message The package at 'Path' failed to uninstall.
So I restart and guess what - it makes no difference. Its not a re-install so the package isnt already there. It does create the folder and contents in the packages folder. I have closed VS and manually deleted it. The same package works fine in another project!
Anybody any ideas how I move this forward?
Thanks in advance.
According to your description, you can try the following methods.
Go to Tools>Options>NuGet Package Manager>General and Clear All NuGet Cache(s).
Restore package.
Reinstall package.
Check your package.config file for package dependencies.

Can't Install Microsoft.EntityFramworkCore.Sqlserver

I am using visual studio 2022 IDE and Despite several attempts I was not able to install the package Microsoft.EntityFramworkCore.Sqlserver.here are my settingsPackage Sources
General
and here is the error message I get:
The feed 'Nuget [https://api.nuget.org/v3/index.json]' lists package 'Microsoft.Data.SqlClient.SNI.runtime.4.0.0' but multiple attempts to download the nupkg have failed. The feed is either invalid or required packages were removed while the current operation was in progress. Verify the package exists on the feed and try again.
Unable to find package 'Microsoft.Data.SqlClient.SNI.runtime.4.0.0'.
The optionsBuilder.UseSqlServer() method does not work in my application because the mentioned package is not available
You can download the package from nuget.org and install it manually.
check out the link Link
Try to install an older version.
Try with 5.0.8

Visual Studio NuGet Cannot Restore Packages

I have a large project that has about a dozen dependencies. I have tried to install them all but ran into an error from VS. I am using Visual Studio 2015
"An error occurred while trying to restore packages: Unable to find version '3.0.3.1' of package'Lucene.Net.Core'."
Now I have a solution which I can use that is by the same name as this package, but VS refuses to let me updates, remove, or change ANYTHING related to these packages and asks that I restore the packages. I am entirely lost here friends, what should I do?
P.S. the two sources I am using for my package sources are:
https://www.nuget.org/api/v2/
https://www.nuget.org/api/v2/curated-feeds/microsoftdotnet/
The same error occurs for Lucene.Net.Contrib, pstsdk.net, and various packages.
One thing to check for is if your project is built on a version of the NET framework that is less than or equal to the target framework the package has.
If your project is a NET 4.5 based project, but the nuget package has a NET 4.5.2... then the package manager will error out.
"An error occurred while trying to restore packages: Unable to find version '3.0.3.1' of package'Lucene.Net.Core'."
When I use the packages sources which you provided, I found that only two versions (4.8.0 & 4.9.0) of package"Lucene.Net.Core" not have the version '3.0.3.1'.
Pay Attention:
I noticed that the author of this package have updated this package at March 11, 2017(3/11/2017), and only release the version 4.8.0 & 4.9.0. So this must be the reason for NuGet restore failed.
Besides, you said:
I have a solution which I can use that is by the same name as this
package, but VS refuses to let me updates, remove, or change ANYTHING
related to these packages
If you want to remove those error packages, you can try to use below command to force uninstall those packages:
Uninstall-Package Lucene.Net.Core -Force
Or you can delete this package from the package folder and delete the package list from the package.config.
Then install the correct version of the packages.
Although I was not able to get any of the posted answers to work, I ended up removing the project entirely and reinstalling VS, my project, and its dependencies. This ended up working.
Another thing to check is that the package manager configuration settings in visual studio list the public nuget feed (and if the feed is enabled too).

Team Foundation Server won't build because nuget packages dont exist

So i created a new solution. Added all my projects to it. Downloaded all the nuget packages.
I checked it all in. On another pc I pulled the solution down. I hit build and I get a tonne of errors relating to not being able to find the dll of the packages.
So I set automatically download packages if they're missing. Still nothing works. Why is this?
When I Enabled it, it came back with an error saying that it could not modify the projects because they were locked.... This is why I want to re-enable the context menu item that allows me to enable nuget to automatically download missing packages.
I think the problem is I checked in all the packages. They all got download onto the other machine, that's why NuGet was saying that I already had the packages.
I solved this by going into the solution directory (physical path) and deleted the packages folder.
Then I built the project, and true to NuGets word it downloaded all the packages again. It also succeeded in building the application, no errors!
I would advise that if you are going to enable the NuGet package restore that you check out the solution first, once you're done check in the solution!

CI Build on TeamCity Fails due to dependency on Microsoft.Bcl

When I try and build my project in Teamcity (or in a clean repository on my machine), it fails with the error message
The schema version of 'Microsoft.Bcl' is incompatible with version 1.7.30402.9028 of NuGet. Please upgrade NuGet to the latest version from <nuget url>...
I've set my NuGet.Targets to restore packages, and not require user interactions to accept licenses. In addition both my local machine and the build server have the restore packages setting enabled (in the project/env variable as appropriate).
I'm aware of this issue http://blogs.msdn.com/b/dotnet/archive/2013/06/12/nuget-package-restore-issues.aspx. I've tried the second and third options suggested here, but without success.
Does anyone have any suggestions how to resolve this error?
Turns out the version of NuGet that is held in the .nuget folder of my solution was out of date. The version that Visual Studio uses had updated correctly, but the command line version didn't.
I followed the instructions described here Nuget versioning issue with package restore to resolve the problem.
In the solution directory run these commands:
cd .nuget
nuget.exe update -Self
Try updating the nuget that teamcity is using
If you are using version 8.x.x
Administration -> Nuget Settings -> Nuget Commandline -> (click fetch nuget) -> then choose the latest version and install it. Make sure "Set as Default" is checked.

Categories