Bug 23759 - Package manager crashes when unselecting custom repository
Summary: Package manager crashes when unselecting custom repository
Status: RESOLVED FIXED
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: NuGet ()
Version: 5.5
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: 5.8
Assignee: Matt Ward
URL:
Depends on:
Blocks:
 
Reported: 2014-10-11 13:30 UTC by Patrick Lind
Modified: 2014-12-16 07:55 UTC (History)
1 user (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Patrick Lind 2014-10-11 13:30:50 UTC
I have a local NuGet repository that I've stored on a local network drive.  I added it as a source to my package manager.  I have two errors related to this:

1.)  My package manager stops working when I'm not within my company vpn (i.e. when it can't see my private NuGet repository)

2.)  If I disable (by unchecking my private NuGet repository as a source) I get this error when I try to add packages:

System.AggregateException: One or more errors occurred ---> System.IO.FileFormatException: Stream length cannot be zero with FileMode.Open
  at System.IO.Packaging.Package.OpenCore (System.IO.Stream stream, FileMode packageMode, FileAccess packageAccess, Boolean ownsStream) [0x0011a] in /private/tmp/source-mono-mac-3.10.0-branch/bockbuild-mono-3.10.0-branch/profiles/mono-mac-xamarin/build-root/mono-3.10.0/mcs/class/WindowsBase/System.IO.Packaging/Package.cs:445 
  at System.IO.Packaging.Package.Open (System.IO.Stream stream, FileMode packageMode, FileAccess packageAccess, Boolean ownsStream) [0x00000] in /private/tmp/source-mono-mac-3.10.0-branch/bockbuild-mono-3.10.0-branch/profiles/mono-mac-xamarin/build-root/mono-3.10.0/mcs/class/WindowsBase/System.IO.Packaging/Package.cs:383 
  at System.IO.Packaging.Package.Open (System.IO.Stream stream, FileMode packageMode, FileAccess packageAccess) [0x00000] in /private/tmp/source-mono-mac-3.10.0-branch/bockbuild-mono-3.10.0-branch/profiles/mono-mac-xamarin/build-root/mono-3.10.0/mcs/class/WindowsBase/System.IO.Packaging/Package.cs:378 
  at System.IO.Packaging.Package.Open (System.IO.Stream stream, FileMode packageMode) [0x0000f] in /private/tmp/source-mono-mac-3.10.0-branch/bockbuild-mono-3.10.0-branch/profiles/mono-mac-xamarin/build-root/mono-3.10.0/mcs/class/WindowsBase/System.IO.Packaging/Package.cs:368 
  at System.IO.Packaging.Package.Open (System.IO.Stream stream) [0x00000] in /private/tmp/source-mono-mac-3.10.0-branch/bockbuild-mono-3.10.0-branch/profiles/mono-mac-xamarin/build-root/mono-3.10.0/mcs/class/WindowsBase/System.IO.Packaging/Package.cs:357 
  at NuGet.OptimizedZipPackage.EnsureManifest () [0x00000] in <filename unknown>:0 
  at NuGet.OptimizedZipPackage..ctor (IFileSystem fileSystem, System.String packagePath, IFileSystem expandedFileSystem) [0x00000] in <filename unknown>:0 
  at NuGet.SharedPackageRepository+SharedOptimizedZipPackage..ctor (IFileSystem fileSystem, System.String packagePath) [0x00000] in <filename unknown>:0 
  at NuGet.SharedPackageRepository+<SearchPackages>d__9.MoveNext () [0x00000] in <filename unknown>:0 
  at System.Linq.Enumerable+<CreateWhereIterator>c__Iterator1E`1[NuGet.IPackage].MoveNext () [0x0006f] in /private/tmp/source-mono-mac-3.10.0-branch/bockbuild-mono-3.10.0-branch/profiles/mono-mac-xamarin/build-root/mono-3.10.0/mcs/class/System.Core/System.Linq/Enumerable.cs:3121 
  at ICSharpCode.PackageManagement.AvailablePackagesViewModel+<GetPrioritizedPackages>c__Iterator1.MoveNext () [0x00190] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-5.5-branch/7b721eee/source/monodevelop/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/AvailablePackagesViewModel.cs:162 
  at System.Collections.Generic.List`1[NuGet.IPackage].AddEnumerable (IEnumerable`1 enumerable) [0x00013] in /private/tmp/source-mono-mac-3.10.0-branch/bockbuild-mono-3.10.0-branch/profiles/mono-mac-xamarin/build-root/mono-3.10.0/mcs/class/corlib/System.Collections.Generic/List.cs:146 
  at System.Collections.Generic.List`1[NuGet.IPackage]..ctor (IEnumerable`1 collection) [0x0002f] in /private/tmp/source-mono-mac-3.10.0-branch/bockbuild-mono-3.10.0-branch/profiles/mono-mac-xamarin/build-root/mono-3.10.0/mcs/class/corlib/System.Collections.Generic/List.cs:69 
  at System.Linq.Enumerable.ToList[IPackage] (IEnumerable`1 source) [0x00006] in /private/tmp/source-mono-mac-3.10.0-branch/bockbuild-mono-3.10.0-branch/profiles/mono-mac-xamarin/build-root/mono-3.10.0/mcs/class/System.Core/System.Linq/Enumerable.cs:2952 
  at ICSharpCode.PackageManagement.AvailablePackagesViewModel+<PrioritizePackages>c__Iterator0.MoveNext () [0x00035] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-5.5-branch/7b721eee/source/monodevelop/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/AvailablePackagesViewModel.cs:136 
  at ICSharpCode.PackageManagement.PackagesViewModel+<ConvertToPackageViewModels>c__Iterator0.MoveNext () [0x000b3] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-5.5-branch/7b721eee/source/monodevelop/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackagesViewModel.cs:332 
  at NuGet.CollectionExtensions.AddRange[PackageViewModel] (ICollection`1 collection, IEnumerable`1 items) [0x00000] in <filename unknown>:0 
  at ICSharpCode.PackageManagement.PackagesViewModel.UpdatePackageViewModels (IEnumerable`1 newPackageViewModels) [0x0001b] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-5.5-branch/7b721eee/source/monodevelop/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackagesViewModel.cs:322 
  at ICSharpCode.PackageManagement.PackagesViewModel.UpdatePackageViewModels (IEnumerable`1 packages, MonoDevelop.PackageManagement.PackageSearchCriteria search) [0x0000c] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-5.5-branch/7b721eee/source/monodevelop/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackagesViewModel.cs:314 
  at ICSharpCode.PackageManagement.PackagesViewModel.UpdatePackagesForSelectedPage (ICSharpCode.PackageManagement.PackagesForSelectedPageResult result) [0x0003b] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-5.5-branch/7b721eee/source/monodevelop/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackagesViewModel.cs:224 
  at ICSharpCode.PackageManagement.PackagesViewModel.OnPackagesReadForSelectedPage (ITask`1 task) [0x0005d] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-5.5-branch/7b721eee/source/monodevelop/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackagesViewModel.cs:180 
  at ICSharpCode.PackageManagement.PackageManagementTask`1[ICSharpCode.PackageManagement.PackagesForSelectedPageResult].OnContinueWith (System.Threading.Tasks.Task`1 task) [0x00008] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-5.5-branch/7b721eee/source/monodevelop/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementTask.cs:59 
  at ICSharpCode.PackageManagement.PackageManagementTask`1[ICSharpCode.PackageManagement.PackagesForSelectedPageResult].<CreateTask>m__0 (System.Threading.Tasks.Task`1 result) [0x00002] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-5.5-branch/7b721eee/source/monodevelop/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementTask.cs:54 
  at System.Threading.Tasks.TaskActionInvoker+ActionTaskInvoke`1[ICSharpCode.PackageManagement.PackagesForSelectedPageResult].Invoke (System.Threading.Tasks.Task owner, System.Object state, System.Threading.Tasks.Task context) [0x00000] in /private/tmp/source-mono-mac-3.10.0-branch/bockbuild-mono-3.10.0-branch/profiles/mono-mac-xamarin/build-root/mono-3.10.0/mcs/class/corlib/System.Threading.Tasks/TaskActionInvoker.cs:200 
  at System.Threading.Tasks.Task.InnerInvoke () [0x00019] in /private/tmp/source-mono-mac-3.10.0-branch/bockbuild-mono-3.10.0-branch/profiles/mono-mac-xamarin/build-root/mono-3.10.0/mcs/class/corlib/System.Threading.Tasks/Task.cs:546 
  at System.Threading.Tasks.Task.ThreadStart () [0x000d0] in /private/tmp/source-mono-mac-3.10.0-branch/bockbuild-mono-3.10.0-branch/profiles/mono-mac-xamarin/build-root/mono-3.10.0/mcs/class/corlib/System.Threading.Tasks/Task.cs:438 
  --- End of inner exception stack trace ---
 --> (Inner exception 0) System.IO.FileFormatException: Stream length cannot be zero with FileMode.Open
  at System.IO.Packaging.Package.OpenCore (System.IO.Stream stream, FileMode packageMode, FileAccess packageAccess, Boolean ownsStream) [0x0011a] in /private/tmp/source-mono-mac-3.10.0-branch/bockbuild-mono-3.10.0-branch/profiles/mono-mac-xamarin/build-root/mono-3.10.0/mcs/class/WindowsBase/System.IO.Packaging/Package.cs:445 
  at System.IO.Packaging.Package.Open (System.IO.Stream stream, FileMode packageMode, FileAccess packageAccess, Boolean ownsStream) [0x00000] in /private/tmp/source-mono-mac-3.10.0-branch/bockbuild-mono-3.10.0-branch/profiles/mono-mac-xamarin/build-root/mono-3.10.0/mcs/class/WindowsBase/System.IO.Packaging/Package.cs:383 
  at System.IO.Packaging.Package.Open (System.IO.Stream stream, FileMode packageMode, FileAccess packageAccess) [0x00000] in /private/tmp/source-mono-mac-3.10.0-branch/bockbuild-mono-3.10.0-branch/profiles/mono-mac-xamarin/build-root/mono-3.10.0/mcs/class/WindowsBase/System.IO.Packaging/Package.cs:378 
  at System.IO.Packaging.Package.Open (System.IO.Stream stream, FileMode packageMode) [0x0000f] in /private/tmp/source-mono-mac-3.10.0-branch/bockbuild-mono-3.10.0-branch/profiles/mono-mac-xamarin/build-root/mono-3.10.0/mcs/class/WindowsBase/System.IO.Packaging/Package.cs:368 
  at System.IO.Packaging.Package.Open (System.IO.Stream stream) [0x00000] in /private/tmp/source-mono-mac-3.10.0-branch/bockbuild-mono-3.10.0-branch/profiles/mono-mac-xamarin/build-root/mono-3.10.0/mcs/class/WindowsBase/System.IO.Packaging/Package.cs:357 
  at NuGet.OptimizedZipPackage.EnsureManifest () [0x00000] in <filename unknown>:0 
  at NuGet.OptimizedZipPackage..ctor (IFileSystem fileSystem, System.String packagePath, IFileSystem expandedFileSystem) [0x00000] in <filename unknown>:0 
  at NuGet.SharedPackageRepository+SharedOptimizedZipPackage..ctor (IFileSystem fileSystem, System.String packagePath) [0x00000] in <filename unknown>:0 
  at NuGet.SharedPackageRepository+<SearchPackages>d__9.MoveNext () [0x00000] in <filename unknown>:0 
  at System.Linq.Enumerable+<CreateWhereIterator>c__Iterator1E`1[NuGet.IPackage].MoveNext () [0x0006f] in /private/tmp/source-mono-mac-3.10.0-branch/bockbuild-mono-3.10.0-branch/profiles/mono-mac-xamarin/build-root/mono-3.10.0/mcs/class/System.Core/System.Linq/Enumerable.cs:3121 
  at ICSharpCode.PackageManagement.AvailablePackagesViewModel+<GetPrioritizedPackages>c__Iterator1.MoveNext () [0x00190] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-5.5-branch/7b721eee/source/monodevelop/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/AvailablePackagesViewModel.cs:162 
  at System.Collections.Generic.List`1[NuGet.IPackage].AddEnumerable (IEnumerable`1 enumerable) [0x00013] in /private/tmp/source-mono-mac-3.10.0-branch/bockbuild-mono-3.10.0-branch/profiles/mono-mac-xamarin/build-root/mono-3.10.0/mcs/class/corlib/System.Collections.Generic/List.cs:146 
  at System.Collections.Generic.List`1[NuGet.IPackage]..ctor (IEnumerable`1 collection) [0x0002f] in /private/tmp/source-mono-mac-3.10.0-branch/bockbuild-mono-3.10.0-branch/profiles/mono-mac-xamarin/build-root/mono-3.10.0/mcs/class/corlib/System.Collections.Generic/List.cs:69 
  at System.Linq.Enumerable.ToList[IPackage] (IEnumerable`1 source) [0x00006] in /private/tmp/source-mono-mac-3.10.0-branch/bockbuild-mono-3.10.0-branch/profiles/mono-mac-xamarin/build-root/mono-3.10.0/mcs/class/System.Core/System.Linq/Enumerable.cs:2952 
  at ICSharpCode.PackageManagement.AvailablePackagesViewModel+<PrioritizePackages>c__Iterator0.MoveNext () [0x00035] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-5.5-branch/7b721eee/source/monodevelop/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/AvailablePackagesViewModel.cs:136 
  at ICSharpCode.PackageManagement.PackagesViewModel+<ConvertToPackageViewModels>c__Iterator0.MoveNext () [0x000b3] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-5.5-branch/7b721eee/source/monodevelop/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackagesViewModel.cs:332 
  at NuGet.CollectionExtensions.AddRange[PackageViewModel] (ICollection`1 collection, IEnumerable`1 items) [0x00000] in <filename unknown>:0 
  at ICSharpCode.PackageManagement.PackagesViewModel.UpdatePackageViewModels (IEnumerable`1 newPackageViewModels) [0x0001b] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-5.5-branch/7b721eee/source/monodevelop/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackagesViewModel.cs:322 
  at ICSharpCode.PackageManagement.PackagesViewModel.UpdatePackageViewModels (IEnumerable`1 packages, MonoDevelop.PackageManagement.PackageSearchCriteria search) [0x0000c] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-5.5-branch/7b721eee/source/monodevelop/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackagesViewModel.cs:314 
  at ICSharpCode.PackageManagement.PackagesViewModel.UpdatePackagesForSelectedPage (ICSharpCode.PackageManagement.PackagesForSelectedPageResult result) [0x0003b] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-5.5-branch/7b721eee/source/monodevelop/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackagesViewModel.cs:224 
  at ICSharpCode.PackageManagement.PackagesViewModel.OnPackagesReadForSelectedPage (ITask`1 task) [0x0005d] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-5.5-branch/7b721eee/source/monodevelop/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackagesViewModel.cs:180 
  at ICSharpCode.PackageManagement.PackageManagementTask`1[ICSharpCode.PackageManagement.PackagesForSelectedPageResult].OnContinueWith (System.Threading.Tasks.Task`1 task) [0x00008] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-5.5-branch/7b721eee/source/monodevelop/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementTask.cs:59 
  at ICSharpCode.PackageManagement.PackageManagementTask`1[ICSharpCode.PackageManagement.PackagesForSelectedPageResult].<CreateTask>m__0 (System.Threading.Tasks.Task`1 result) [0x00002] in /Users/builder/data/lanes/monodevelop-lion-monodevelop-5.5-branch/7b721eee/source/monodevelop/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementTask.cs:54 
  at System.Threading.Tasks.TaskActionInvoker+ActionTaskInvoke`1[ICSharpCode.PackageManagement.PackagesForSelectedPageResult].Invoke (System.Threading.Tasks.Task owner, System.Object state, System.Threading.Tasks.Task context) [0x00000] in /private/tmp/source-mono-mac-3.10.0-branch/bockbuild-mono-3.10.0-branch/profiles/mono-mac-xamarin/build-root/mono-3.10.0/mcs/class/corlib/System.Threading.Tasks/TaskActionInvoker.cs:200 
  at System.Threading.Tasks.Task.InnerInvoke () [0x00019] in /private/tmp/source-mono-mac-3.10.0-branch/bockbuild-mono-3.10.0-branch/profiles/mono-mac-xamarin/build-root/mono-3.10.0/mcs/class/corlib/System.Threading.Tasks/Task.cs:546 
  at System.Threading.Tasks.Task.ThreadStart () [0x000d0] in /private/tmp/source-mono-mac-3.10.0-branch/bockbuild-mono-3.10.0-branch/profiles/mono-mac-xamarin/build-root/mono-3.10.0/mcs/class/corlib/System.Threading.Tasks/Task.cs:438
Comment 1 Matt Ward 2014-10-18 09:20:51 UTC
1) when you say the package manager stops working what happens? Do you get the error you see in 2) or something else happens?

Is your private NuGet source selected in the Add Packages dialog or are you using All Sources?

2) I am assuming your private NuGet source is a directory (not a web server) on the network drive which is only accessible when you are on the VPN.

Looking at the code which is throwing an exception it seems to be failing to read the packages in your solution's packages directory. Is this packages directory on the network drive?
Comment 2 Patrick Lind 2014-10-18 10:29:26 UTC
So this may be a different issue than what I thought...  I removed the custom source and still got the error.  I then opened a new project and noticed the package manager was working fine.  Once I physically went into the packages directory on the problem solution and removed my custom package by hand it started working properly again.  This has to be something with my changing the package set up and the project still expecting to see the old one or something like that.
Comment 3 Matt Ward 2014-10-18 10:40:35 UTC
Was the NuGet package you removed zero bytes?
Comment 4 Patrick Lind 2014-10-18 11:04:54 UTC
I didn't think so but I didn't check to be honest.  Not sure what a zero byte package would have to do with not even being able to view official packages...
Comment 5 Matt Ward 2014-10-18 11:26:49 UTC
I can reproduce the problem with a zero byte .nupkg file in the solution's packages directory. I get the same FileFormatException: "Stream length cannot be zero with FileMode.Open" after the Add Packages dialog does nothing for a while.

The reason a zero byte package affects being able to view official packages is how the Add Packages dialog works. When the dialog is opened it shows a list of the recently installed packages, the packages in the current solution and the packages from the selected package source.

Xamarin Studio should handle this by either ignoring the error or by displaying it in the dialog but still showing NuGet packages in its list.
Comment 6 Matt Ward 2014-12-16 07:55:13 UTC
The exception when the .nupkg is zero bytes should now be fixed in:

Xamarin Studio: 5.8.0.100 (master branch)
Commit: https://github.com/mono/monodevelop/commit/cf03a223bdc43f48b9e19e4055a11b0bd3a0a265

If there is a .nupkg file that is zero bytes now you will see NuGet packages in the dialog and there will be an error message shown. You will not be able to add packages to the project unless this invalid .nupkg file is removed.