Reputation: 1678
I was able to set up my own NuGet server (as described here).
The server Packages
folder contains several versions of MyPackage
, say 1.0.8.0 and 1.0.9.0.
When I install it in a default way (with no version specified), it gets installed successfully. But when I explicitly do
Install-Package MyPackage -Version 1.0.9.0
it goes wrong with the following message:
Install-Package : Unable to find version '1.0.9.0' of package 'MyPackage'. At line:1 char:16 + install-package <<<< MyPackage -Version 1.0.9.0 + CategoryInfo : NotSpecified: (:) [Install-Package], InvalidOperationException + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand
UPDATE:
This error message appears when Package Source
in Package Manager Console is set to "ALL". When I set it to my own source (where, in fact, the package is expected to be found), another error appears:
Install-Package : **There are multiple root elements. Line 42, position 2.**
At line:1 char:16
+ install-package <<<< dfct.shell.core.contracts -Version "1.0.8.0"
+ CategoryInfo : NotSpecified: (:) [Install-Package], XmlException
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand
Multiple root elements, Line 42? In what file? Why is that? I think there's something wrong on the server side, but can't figure out what it is.
Upvotes: 3
Views: 1713
Reputation: 70274
Got a similar error when trying to install EntityFramework
.
PM> Install-Package EntityFramework -Version 6.1.3
Attempting to gather dependency information for package 'EntityFramework.6.1.3' with respect to project 'Project.Data.Entities', targeting '.NETFramework,Version=v4.6.1'
Gathering dependency information took 6,19 ms
Attempting to resolve dependencies for package 'EntityFramework.6.1.3' with DependencyBehavior 'Lowest'
Resolving dependency information took 0 ms
Resolving actions to install package 'EntityFramework.6.1.3'
Resolved actions to install package 'EntityFramework.6.1.3'
Found package 'EntityFramework 6.1.3' in 'C:\dev\ProjectSource\packages'.
Package 'EntityFramework.6.1.3' already exists in folder 'C:\dev\ProjectSource\packages'
Install failed. Rolling back...
Package 'EntityFramework.6.1.3' does not exist in project 'Project.Data.Entities'
Executing nuget actions took 695,25 ms
Install-Package : There are multiple root elements. Line 22, position 2.
At line:1 char:1
+ Install-Package EntityFramework -Version 6.1.3
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
Time Elapsed: 00:00:01.1494321
Turned out App.config
had become corrupt, probably when upgrading target framework
. There was now two </configuration>
and <startup>
was a new root element, therefore the error multiple root elements
.
Corrupt:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
</configSections>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework"/>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
</providers>
</entityFramework>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="RabbitMQ.Client" publicKeyToken="89e7d7c5feba84ce" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.6.9.0" newVersion="3.6.9.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/></startup></configuration>
Manually fixed version:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
</startup>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework"/>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
</providers>
</entityFramework>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="RabbitMQ.Client" publicKeyToken="89e7d7c5feba84ce" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.6.9.0" newVersion="3.6.9.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Upvotes: 0
Reputation: 1678
Turned out that coexistence of both MyPackage.1.0.9.0.nupkg
and MyPackage.1.0.9.0.symbols.nupkg
caused NuGet to crash. NuGet uses OData as transport and somewhere deep in OData it could not serialize/deserialize two packages, complaining about "multiple root nodes".
So I simply removed -symbols
from nuget pack
command line thus disabling debug packages generation, and now it all works fine.
Upvotes: 5