Nuget Cannot find system packages - c#

I have a webforms application that builds and runs on localhost without difficulties but fails to do so when publishing to an azure web app as it gives the following errors:
Severity Code Description Project File Line Suppression State Error NuGet Package restore failed for project OpenRep: Unable to find version '4.0.11' of package 'System.Text.Trim().Encoding'.
C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\: Package 'System.Text.Trim().Encoding.4.0.11' is not found on source 'C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\'.
https://api.nuget.org/v3/index.json: Package 'System.Text.Trim().Encoding.4.0.11' is not found on source 'https://api.nuget.org/v3/index.json'.
https://www.nuget.org/api/v2/curated-feeds/microsoftdotnet/: Package 'System.Text.Trim().Encoding.4.0.11' is not found on source 'https://www.nuget.org/api/v2/curated-feeds/microsoftdotnet/'.
I have tried reinstalling packages on the nuget package manager console but this won't work either. I also thought that the system packages came default with VS.

Related

Xamarin Forms iOS and Android projects not able to run In Mac?

The below are the issues I am getting when I am cleaning and Building the project.
When we are running the project iOS or Android both is occurring same
error:
/Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/xbuild/Current/Microsoft.Common.props(3,3): Error MSB4019: The imported project "/Users/…..iOS/obj/ABSConfigurator.iOS.csproj.*.props" was not found. Confirm that the expression in the Import declaration “ABSConfigurator.iOS.csproj.*.props" is correct, and that the file exists on disk. (MSB4019)
When I am restoring the package then below are the error:
Error: NuGet packages need to be restored before building. NuGet MSBuild targets are missing and are needed for building. The NuGet MSBuild targets are generated when the NuGet packages are restored.

Why am I getting errors when trying to restore NuGet packages in Visual Studio 2022?

I have a .Net Core application using Visual Studio 2022.
I am running into difficulties managing my NuGet packages.
When I attempt to do a NuGet package restore on the solution, I get the following error message:
NuGet package restore failed. Please see Error List window for
detailed warnings and errors. Time Elapsed: 00:00:00.1126945
========== Finished ========== Error occurred while restoring NuGet packages: The local source 'C:\Program Files (x86)\DevExpress
19.2.NET Core Desktop Libraries\System\Components\Packages' doesn't exist.
I tried clearing the cache from Tools->Options->NuGet Package
Manager->Clear All NuGet Caches.
I also tried manually deleting my NuGet.config in my folder: C:\Users\foobar\AppData\Roaming\NuGet
I still get the same error.
DevExpress 19.2 is not used or referenced by any of the projects in my solution. At one point I had it installed on my machine, but removed it. I'm currently using the DevExpress 21.2.
I've been trying to figure this out for a couple of days. How do I fix this issue? Is there a cache somewhere that I am unaware of? Will I have to uninstall/reinstall Visual Studio?
The error you're getting show a route: 'C:\Program Files (x86)\DevExpress 19.2.NET Core Desktop Libraries\System\Components\Packages' this is maybe beacuse you have it in your Package sources, you need to delete it from there and then restore the packages with the correct source:
Package Source
You can check your package source and update your local path here:

File was not found after nuget restore

I am using Visual Studio 2017 and pull the source code from TFS server, then build the solution, I got the following error:
Microsoft.Common.CurrentVersion.targets (3863,5): Error MSB3113: The
file "SqlServerTypes \ x64 \ SqlServerSpatial140.dll" was not found.
Then I found this dll file comes from the nuget package sqlserver.types, as I know, Visual Studio will restore the nuget packages when we build the solution.
Why I still have this issue?
File was not found after nuget restore
When you download the nuget package Microsoft.SqlServer.Types from the nuget.org and open it with nuget package explorer:
You will find the sqlserver.types nuget package not only includes .dll from .net framework, but also has native binaries files. These files are designed with x64 and x84, they could not added to lib folder directly. So the package owner adds them to project as content. However, these dll files is setting to ignore by default for TFS, you need to add them manually.
Of course, you can also use the command line Update-Package <package_name> –reinstall to reinstall this nuget package, but this requires you to execute this command every time after you pull the code from the TFS server. Add this native binaries to the source control will Will reduce these unnecessary troubles.
Hope this helps.
You can try this:
Update-Package <package_name> –reinstall

Getting NuGet compile error only on specific branch - Visual Studio 2015

I'm getting 3 types of errors when trying to build the project from a specific branch.
In the others branchs it works properly.
These are the problems:
1- The command ""D:\Web\Hom\.nuget\NuGet.exe" install "D:\Web\Hom\ServiceClient\packages.config" -source "" -NonInteractive -RequireConsent -solutionDir "D:\Web\Hom\ "" exited with code 1.
2- Unable to find version '1.0.4632' of package 'AppFabric'.
3- NuGet Package restore failed for project Web.ServiceClient: Unable to find version '1.0.4632' of package 'AppFabric'.
C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\: Package 'AppFabric.1.0.4632' is not found on source 'C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\'.https://api.nuget.org/v3/index.json: Package 'AppFabric.1.0.4632' is not found on source 'https://api.nuget.org/v3/index.json'
NuGet will restore packages to the packages directory based on the packages.config file. Please compare the packages.config in specific branch with others branches, the package “AppFabric” element exists in the specific branch. So the NuGet would download the “AppFabric” package from the package Sources before project compiled.
According to the error messages, the “AppFabric” package has not been published to the NuGet server, NuGet could not download it from the NuGet server. You can according to the following methods to resolve this problem:
(1) Download the “AppFabric” package, Creating a local NuGet repository, add this package to the repository.
(2) Download the “AppFabric” package, publish this package to the NuGet server before the project compiled.
Note that: You need to use "Update-Package -reinstall" command in Package Manager Console force reinstall the package references and content files into project after restore successfully.

Nuget Restore via build server "unable to find version"

I have a VS solution and as part of a TeamCity Build, we restore packages from both a private NuGet feed (myget) and the public feed (nuget.org). Most packages restore fine, but it hangs on the ones below for WebApi and Mono.Security. This is all working locally in Visual Studio.
[restore] NuGet command: C:\TeamCity\buildAgent\plugins\nuget-agent\bin\JetBrains.TeamCity.NuGetRunner.exe C:\TeamCity\buildAgent\tools\NuGet.CommandLine.DEFAULT.nupkg\tools\NuGet.exe restore C:\TeamCity\buildAgent\work\953bd084b49f7d88\DataFinch.Web.sln -Source https://www.myget.org/F/datafinch/auth/<hidden>/api/v2 -Source https://api.nuget.org/v3/index.json
[11:41:35][restore] Starting: C:\TeamCity\buildAgent\temp\agentTmp\custom_script473789219385667038.cmd
[11:41:35][restore] in directory: C:\TeamCity\buildAgent\work\953bd084b49f7d88
[11:41:35][restore] JetBrains TeamCity NuGet Runner 8.0.37059.9
[11:41:35][restore] Registered additional extensions from paths: C:\TeamCity\buildAgent\plugins\nuget-agent\bin\plugins-2.8
[11:41:35][restore] Starting NuGet.exe 2.8.50926.602 from C:\TeamCity\buildAgent\tools\NuGet.CommandLine.DEFAULT.nupkg\tools\NuGet.exe
[11:41:43][restore] Unable to find version '5.2.3' of package 'Microsoft.AspNet.WebApi.Client'.
[11:41:43][restore] Unable to find version '5.2.3' of package 'Microsoft.AspNet.WebApi.Core'.
[11:41:43][restore] Unable to find version '3.2.3.0' of package 'Mono.Security'.
[11:41:43][restore] Unable to find version '6.0.4' of package 'Newtonsoft.Json'.
[11:41:43][restore] Process exited with code 1
Teamcity config:
Try using https://www.nuget.org/api/v2instead of https://api.nuget.org/v3/index.json per the nuget docs: https://docs.nuget.org/consume/Command-Line-Reference.
The reason why the build failed, was an old version of nuget.exe. I finally solved this problem by downloading the latest version and put this executable in the Program Files x86 folder. Then I created a new system variabele to point to this executable. After that I add a NuGetInstaller package in my TFS Build Definition to let me configure TFS using this new NuGet.exe.
This link helped me to let TFS use this new NuGet version
I followed this: https://blogs.msdn.microsoft.com/tfssetup/2017/04/18/tfs-2017-update-1-nuget-restore-task-always-fails-trying-to-find-packages-even-though-they-exist-on-the-feed/
I had tried 3.3 and got this error:
Restoring NuGet package Microsoft.AspNet.WebPages.3.2.3.
WARNING: Unable to find version '3.5.0.2' of package 'Antlr'.
I downloaded the latest NuGet 4.3.0.4406 and set the Custom path to NuGet and that failed as well.
Surprisingly when I switched to 3.5 it worked.
If you are really stuck, run the command in a Command Line Prompt and it will work:
C:\Program Files (x86)\NuGet\nuget.exe restore -NonInteractive E:\agentXYZPool\_work\1\s\xyz.sln
I ran into this problem with one of our build slaves leveraging TFS and Visual Studio.
The way I fixed it was, I opened the solution that wasn't compiling in Visual Studio, right-clicked on the SLN and selected "Enable Restore NuGet Packages"
That prompts a dialog box that you have to accept. After you've done that, you might be good to go. Right-click on the SLN again and run "Restore NuGet Packages", and if that operation succeeds, you're golden.
There's probably some setting you can adjust programmatically when setting up your slave environments, but that's one direct way to fix this kind of problem.
According to THIS current document as of this writing from MS, the proper url is: https://api.nuget.org/v3/index.json
So I went about to fix the issue because I assumed it had nothing to do with the URL. I did 2 things, not sure which it was that resolved the issue but I'll post both here in case it helps someone.
Within TFS2018 and within my build step for the installation of Nuget I specified version 4.9.3 (the reason I chose 4.9.3 because I noticed by looking at detailed log of VS that during my build it was using this version) and chose to always download the latest version.
Second thing I did was I removed a Nuget.Config file from my project that was left over from something I was testing. Then I re-commited my changes to TFS
After I did both of the above steps the rest of my build started working.
Using an old version of Visual Studio's Nuget
Visual Studio has C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\Nuget.exe. Jenkins was using that to nuget restore
Updated Nuget in program files,
C:\Program Files (x86)\NuGet> ./nuget.exe update -self
Pointed Jenkins at that new Nuget path and 🔥cooking with gas🔥
SET PATH=%PATH%;C:\Program Files (x86)\NuGet
nuget restore SolutionName.sln

Categories

Resources