Build a C# project fails in nuget restore package Microsoft.ApplicationInsights - nuget

I have this Azure Notification Hubs Sample
and it fails because
The 'Microsoft.ApplicationInsights 0.12.0-build17386' package requires
NuGet client version '2.8.50313' or above, but the current NuGet
version is '2.8.1.0'. The command "eval nuget restore
src/NotificationHubSample.sln" failed. Retrying, 2 of 3.
why?

It is a problem with the Microsoft.ApplicationInsights NuGet package. In its .nuspec file it has the following:
<metadata minClientVersion="2.8.50313">
NuGet will check the minClientVersion defined by a NuGet package against its product version to see if they are compatible.
The minClientVersion used in the Microsoft.ApplicationInsights NuGet package seems to be using the NuGet assembly file version and not the NuGet product version. So NuGet restore or install will always fail, at least until a newer version of NuGet is released. The latest NuGet released has a product version of 2.8.3.
Note that I am ignoring NuGet 3.0 which currently has a CTP release. So this NuGet package would work with NuGet 3.0 so maybe the creators of the Microsoft.ApplicationInsights NuGet package have only tested it with that version.
So your options are:
Report the problem to the owners of the Microsoft.ApplicationInsights NuGet package and wait for them to fix it.
Use NuGet.exe 3.0 to run the package restore with Travis.
Use a different version of the Microsoft.ApplicationInsights NuGet package which does not have this minClientVersion restriction.

Related

Installing Nuget Gets Dependencies Only

I have a .NET Framework 4.5 project. I'm trying to install Microsoft.NET.Test.Sdk. This should be possible as per https://www.nuget.org/packages/Microsoft.NET.Test.Sdk/
I ran the following command, but get the dependencies only. I tried installing via the Nuget Package Manager too. Finally... I see the package inside my packages.config file, but don't see it in my references. Any suggestions?
Install-Package Microsoft.NET.Test.Sdk -Version 15.7.0
I ended up using Microsoft.VisualStudio.TestTools.UnitTesting.

NuGet restore fails with "Package contains multiple nuspec files" on my machine only

I am using VS2015U3 and NuGet 3.4.4. running on Windows 10 Anniversary Update.
NuGet restore gives this error when run in Visual Studio or when run on the command line.
I've tested this on two independent solution files with the same results. However the build server and my laptop restore packages without any problem.
I've tried downloading NuGet.exe fresh, repairing Visual Studio, Uninstalling and Reinstalling the NuGet Package manager and clearing the NuGet cache.
Here is the output from running NuGet restore ..\mySolution.sln on the command line:
Restoring NuGet package RestSharp.102.7.0.
Restoring NuGet package Rx-Core.2.2.5.
Restoring NuGet package Rx-Interfaces.2.2.5.
Restoring NuGet package Newtonsoft.Json.4.0.8.
Restoring NuGet package Rx-Linq.2.2.5.
Restoring NuGet package Rx-Main.2.2.5.
Restoring NuGet package Rx-PlatformServices.2.2.5.
Restoring NuGet package Rx-WPF.2.2.5.
Restoring NuGet package Rx-XAML.2.2.5.
Restoring NuGet package LiveCharts.0.6.5.
Restoring NuGet package CommandLineParser.1.9.71.
WARNING: Package contains multiple nuspec files.
Errors in packages.config projects
Package contains multiple nuspec files.
NuGet Config files used:
C:\Users\Rob\AppData\Roaming\NuGet\NuGet.Config
C:\ProgramData\nuget\Config\Microsoft.VisualStudio.Offline.config
Feeds used:
C:\Users\Rob\AppData\Local\NuGet\Cache
C:\Users\Rob.nuget\packages\
https://api.nuget.org/v3/index.json
C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\
Running "Nuget.exe locals all -clear" fixed this

Nuget Package Manager for single project fails to load after adding RingCentralSDK

I'm on VS 2015, targeting .net 4.5.2, my "Nuget Package Manager for Visual Studio" in Extensions and Updates shows 3.4.4.1321.
I added all dependencies of RingCentralSDK package separately:
Microsoft.Bcl
Microsoft.Bcl.Async
Microsoft.Bcl.Build
Microsoft.Net.Http
Newtonsoft.Json
Portable.BouncyCastle-Signed
PubnubPCL
Then I right click on my project, pick "Manage Nuget Packages...", the tab opens, in the "Installed" subtab I can see the 7 packages.
Now, I install the RingCentralSDK package. My output is fine:
Attempting to gather dependency information for package 'RingCentralSDK.1.0.0' with respect to project 'MyProj', targeting '.NETFramework,Version=v4.5.2'
Attempting to resolve dependencies for package 'RingCentralSDK.1.0.0' with DependencyBehavior 'Lowest'
Resolving actions to install package 'RingCentralSDK.1.0.0'
Resolved actions to install package 'RingCentralSDK.1.0.0'
Adding package 'RingCentralSDK.1.0.0' to folder 'C:\code\packages'
Added package 'RingCentralSDK.1.0.0' to folder 'C:\code\packages'
Added package 'RingCentralSDK.1.0.0' to 'packages.config'
Successfully installed 'RingCentralSDK 1.0.0' to MyProj
========== Finished ==========
Now, I check again the Manage Nuget Packages for this specific project, and instead of seeing the list of packages, I get a yellow band:
Error occured Show erros in output Dismiss
And in the "Package Manager" output, the error is:
ZIP archive contains unsupported data structures.
In my packages folder, the folder "RingCentralSDK.1.0.0" seems ok, but then I don't anything about nuget packages format.
I cannot uninstall RingCentral via the package manager as it's not showing, not any other one, which is really annoying. I had an error when trying to do it via the command line. I reverted my changes (or remove the line in packages.config for my project), and the Nuget Package Manager tab works fine again. This is also affecting the "Managet Nuget Packages for Solution".
What can I do to fix this?
Fixed in RingCentralSDK 1.0.1-alpha1
It turns out that the NuGet package created on Mac is not compatible with Visual Studio NuGet GUI tool.
You can install the latest version by
Install-Package RingCentralSDK -Pre
Or if you prefer GUI:
Update:
For projects which already have 1.0.0 version installed, how to upgrade?
Today I did some testing and I came to the following conclusion:
New project will have no problem with 1.0.1 version or later
For old project which have 1.0.0 installed. You need to follow the following steps:
UnInstall RingCentralSDK 1.0.0
Close VS
Delete packages folder in your project
Delete packages folder in ~/.nuget/
Launch VS
Install RingCentralSDK 1.0.1
I need to do the above because nuget has cache. If I don't do it the problem just persists. I don't know the exactly reason but the above steps did work for me.

Nuget not reinstalling packages

I have modified the target .net framework to use 4.5 from 4.0. I got a message from nuget that packages need to re-installed so ran Update-Package -Reinstall -ProjectName https://localhost/SomeWebProject/. As nuget was executing, it spitted out yellow warning signs that looked like this:
Skipped reinstalling package 'NLog 3.1.0.0' in project 'SomeWebProject' because the package does not exist in the package source.
Why aren't my packages being reinstalled? I went into my packages folder and verified NLog 3.1.0.0 exist!
Turns out the solution is hiding in plain sight.
All we have to do is set the Package Source in the Package Manager Console window. (Credits to Matt Ward for pointing it out.)
Or you may run the following NuGet Package Management command:
'Update-Package -reinstall'
This command will reinstall all your solutions NuGet packages without updating the version(s) of existing packages.

How can I keep nuget from updating dependencies?

I'm attempting to install a nuget package which has incorrectly specified one of it's dependencies. Common.Logging.Log4Net requires log4net = 1.2.10 however the nuget package specifies log4net >= 1.2.10. Even if I manually install the older version of log4net, nuget upgrades log4net to 1.2.11 when I install Common.Logging.Log4Net. How can I get nuget to bypass dependency resolution or at least prefer installed packages of a sufficient version?
In order to bypass dependency resolution you can use the -IgnoreDependencies option:
Install-Package -IgnoreDependencies ThePackageName
You should be able to lock the package to a specific version by hand-editing the packages.config and setting the allowedVersions attribute to indicate the version span you want to allow.
<package id="Common.Logging.Log4Net" version="1.2.10"
allowedVersions="[1.2,1.2.10]" />
Note that his will however not upgrade the version of the package at all even when explicitly updating the package.
See the nuget versioning documentation for more info on versioning.