On any package I try to install I'm getting the following exception:
install-package : Unexpected XML declaration. The XML declaration must be the first node in the document, and no white space characters are allowed to appear before it. Line 1, position 16.
I'm really frustrated with this issue tried everything, I can't find what xml has this unexpected char.
!!! PLEASE HELP !!!
I know its been a while since you have posted this issue and probably have already solved it by now. But just as a reference for anybody else, I've had a similar scenario recently while trying to install some packages hosted on an internal nuget server and faced the exact same problem.
Install-Package : Unexpected XML declaration. The XML declaration must be the first node in the document, and no white space characters are allowed to appear before it. Line 140, position 3.
At line:1 char:16
+ install-package <<<< hydro
+ CategoryInfo : NotSpecified: (:) [Install-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
The solution - I was able to solve it by undoing all the changes I made to the web.config file and reset it to its default template. After that the installation went through fine. The package was trying to add some runtime assembly bindings to the web.config file but I had copied some of these binding from another project which wasn't necessary.
Other possible scenarios- We should keep in mind that nuget packages not only add assemblies to a project but also allows you to inject content/source code, run scripts apart from editing configuration files such as web.config or app.config.
The error unfortunately being non-specific might be hard to trace, but you could try to install the package on a brand new project and see if everything goes well, then try and deduce which component/file/folder addition is causing the reinstallation of the package to fail. Here is more information on what nuget can do during package installations. Hope this helps.