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

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.

Related

Can't install or update any nuget packages in my project in vs2017

When I used vs2015, packages were added to a packages folder in my solution and a package.config file was added and also reference includes in the csproj file. But since I use vs2017 I'm not able to install or update any nuget packages, although the packages are downloaded and unzipped in this location:
C:\Users\user.nuget\packages:
packages
I tried both Manage Nuget Packages and Package Manager Console, but I get the errors "Install failed. Rolling back." and "Could not add reference, dll not registered." I tried installing webview2, newtonsoft json and restsharp but get the same errors.
Here's the output:
output packetmanager
So how can I download and unzip a package into a package folder in my solution and install it in my project ?

Nuget package manager failed for project, Unable to find version 5.2.6 of package ‘Microsoft.AspNet.Mvc

I try to set up an application but I am facing the below error:
Nuget package restore failed for project ProjectName: Unable to find version ‘5.2.6’ of package ‘Microsoft.AspNet.Mvc’. C:/Program Files (x86)\Microsoft SDKs\NugetPackages: Package ‘Microsoft.AspNet.Mvc.5.2.6’ is not found on source ‘c:\Program files (x86)\Microsoft SDKs\NugetPackages\’. http://ncrsdk-lib.ncrcorp******** : Package ‘Microsoft.AspNet.Mvc.5.2.6’ is not found on source ‘http://ncrsdk-lib.ncrcorp.net/********’*
I tried to run the following command in the package manager console:
PM> Install-Package Microsoft.AspNet.Mvc -Version 5.2.6
I got the error some packages are missing from the solution. The package needs to be restored In order to build the dependency graph.
I clicked on the restore packages button and that gives a message unable to restore.
I cleared the package cache and added nuget.org to the package sources(was missing before) , This fixed the issue.
Source - An error occurred while trying to restore packages. Please try again
The package does not exist in the mentioned source , try to point your source to official nuget.org website , you have to options in order to force it to point to the correct one
Command Line
Install-Package Microsoft.AspNet.Mvc -Version 5.2.6 -Source https://api.nuget.org/v3/index.json
Or from Visual Studio you can select the correct source or configure a new source to point the official nuget.org
From the error message looks like you are looking for a version that no longer exists and cannot tell which Package source you have selected.
Its trying to download the package form "http://ncrsdk-lib.ncrcorp********" where as the package may be removed from there. Try installing the the same package from source nuget.org only.

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

Nuget Cannot find system packages

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.

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