NuGet v1.1 Upgrade problems

Feb 23, 2011 at 7:03 PM

I had been using NuGet v1.0.11220.104 without problems in an MVC3 application. I successfully upgraded using VS to v1.1.229.160 and now loading the console errors out. I've verified that 'Scripts\nuget.psm1' does exist on disk at:

C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Microsoft Corporation\NuGet Package Manager\1.1.229.160\Scripts

 

System.Management.Automation.CmdletInvocationException: Could not load file or assembly 'Scripts\nuget.psm1' or one of its dependencies. The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG)) ---> System.IO.FileLoadException: Could not load file or assembly 'Scripts\nuget.psm1' or one of its dependencies. The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG)) ---> System.ArgumentException: Illegal characters in path.
   at System.IO.Path.CheckInvalidPathChars(String path)
   at System.IO.Path.Combine(String path1, String path2)
   at Microsoft.VisualStudio.Platform.VsAppDomainManager.<AssemblyPaths>d__1.MoveNext()
   at Microsoft.VisualStudio.Platform.VsAppDomainManager.InnerResolveHandler(String name)
   at Microsoft.VisualStudio.Platform.VsAppDomainManager.ResolveHandler(Object sender, ResolveEventArgs args)
   at System.AppDomain.OnAssemblyResolveEvent(RuntimeAssembly assembly, String assemblyFullName)
   --- End of inner exception stack trace ---
   at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadBinaryModule(Boolean trySnapInName, String moduleName, String fileName, Assembly assemblyToLoad, String moduleBase, SessionState ss, String prefix, Boolean loadTypes, Boolean loadFormats, Boolean& found)
   at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadModuleNamedInManifest(String moduleName, String moduleBase, Boolean searchModulePath, String prefix, SessionState ss, Boolean loadTypesFiles, Boolean loadFormatFiles, Boolean& found)
   at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadModuleManifest(ExternalScriptInfo scriptInfo, ManifestProcessingFlags manifestProcessingFlags, Version version)
   at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadModule(String fileName, String moduleBase, String prefix, SessionState ss, Boolean& found)
   at Microsoft.PowerShell.Commands.ImportModuleCommand.ProcessRecord()
   at System.Management.Automation.Cmdlet.DoProcessRecord()
   at System.Management.Automation.CommandProcessor.ProcessRecord()
   --- End of inner exception stack trace ---
   at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
   at System.Management.Automation.Runspaces.Pipeline.Invoke()
   at NuGetConsole.Host.PowerShell.Implementation.PowerShellHost.Invoke(String command, Object input, Boolean outputResults)
   at NuGetConsole.Host.PowerShell.Implementation.PowerShellHostExtensions.ImportModule(PowerShellHost host, String modulePath)
   at NuGetConsole.Host.PowerShell.Implementation.PowerShellHost.LoadStartupScripts()
   at NuGetConsole.Host.PowerShell.Implementation.PowerShellHost.Initialize()
   at NuGetConsole.Implementation.Console.ConsoleDispatcher.Start()
   at NuGetConsole.Implementation.PowerConsoleToolWindow.MoveFocus(FrameworkElement consolePane)

Feb 23, 2011 at 7:22 PM

What is your OS locale?

Feb 23, 2011 at 7:56 PM

en-us. For the record I have tried un-installing and installing again several times. 

Feb 23, 2011 at 9:03 PM

I had this same problem. It was because I had installed Reflector a long time ago and it installed that 14day trial of the Visual Studio addon. I went into reflector, under options and disabled the Visual Studio integration. That worked fine

Feb 23, 2011 at 9:10 PM

Can you grab the latest nightly build bits from our CI machine and try it out to see if you can repro it? http://ci.nuget.org:8080/guestAuth/repository/download/bt4/.lastSuccessful/VisualStudioAddIn/NuGet.Tools.vsix

Feb 23, 2011 at 9:14 PM

@darthobiwan: Thanks for the info. We have had various problems with that Reflector add-in in the past. Now it comes back and bites us.

Maybe we NuGet should detect the presence of Reflector and gives a warning.

Feb 23, 2011 at 9:17 PM

That doesn't sound like the same issue to me. If it were, it would have happened with 1.0, not just when upgrading to 1.1. Also, the error looks different. This looks like a problem with some path being improperly quoted. WHat is nuget.psm1, and where is it supposed to load from?

Feb 23, 2011 at 9:24 PM

It's not the same issue, but may be caused by the same reason, Reflector. We introduced nuget.psd1 module manifest in 1.1, which is what's causing nuget.psm1 to be loaded in the callstack. We didn't have nuget.psd1 in 1.0, so that's why he didn't have issue in 1.0.

nuget.psm1 is our nuget module (which does the tab expansion.) It's supposed to be inside Scripts folder. According to oisin, the Reflector addin may be munging with the application base path.

Feb 23, 2011 at 9:33 PM

Disabling the Reflector add-in seemed to fix the issue. I couldn't find a way to completely uninstall in (either in add/remove programs or VS itself)

Feb 23, 2011 at 9:35 PM

Wow, that that was it then! That thing has been nothing but problems. Hopefully, now that they switched their business model, less people will end up with it randomly installed. :)

Feb 23, 2011 at 9:44 PM
Edited Feb 23, 2011 at 9:48 PM

@mdarnall: If you want to uninstall that evil addin completely, just delete the assembly RedGate.Reflector.AddIn.dll from C:\Users\<user>\Documents\Visual Studio 2010\Addins.

But before you delete, can you (both mdarnall and darthobiwan) share the version of Reflector that you have? We want to put it in our Known Issues page.

Feb 23, 2011 at 9:55 PM

My version was 6.1

Feb 24, 2011 at 1:24 AM

Yeah, AFAICT, one of the things the Reflector add-in does is hook into VS's AppDomain's AssemblyResolve chain so it can monitor and on-the-fly decompile linked assemblies. This is part of its magic "pro" functionality that lets you single-step through assemblies without having source. The bug seems to be trigged by a code path that covers probing for assemblies in the appdomain's private probing path, not the GAC. The exception occurs deep within Visual Studio's code, not ours. It might be screwed up for him because of a bug in Reflector, or because the the pro version is expired and is return crap (or throwing.)

Feb 24, 2011 at 5:32 PM

@mdarnall: If you upgrade Reflector to the latest version 6.5, I believe it will also fix the problem. This is stated in our Known Issues page (http://nuget.codeplex.com/documentation?title=Known%20Issues)

Feb 25, 2011 at 1:20 PM

I also had the same issue with the 6.1 version of the Reflector Add-In. Thanks for the link to the known issues.

Feb 25, 2011 at 3:49 PM

I have the same issue and tried everything suggested and still get the same error.

I uninstalled all addins that I had (PostSharp, VisualSVN), I had used reflector before so I made sure to upgrade to 6.5, install the addin, removed the addin.  Still same error.

Is there anything else I can look for?

Feb 25, 2011 at 8:16 PM

@sjeffrey: are you getting the exact same error as the original mail in the thread, or some other failure?

Feb 25, 2011 at 8:50 PM

System.Management.Automation.CmdletInvocationException: Could not load file or assembly 'Scripts\nuget.psm1' or one of its dependencies. The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG)) ---> System.IO.FileLoadException: Could not load file or assembly 'Scripts\nuget.psm1' or one of its dependencies. The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG)) ---> System.ArgumentException: Illegal characters in path.
   at System.IO.Path.CheckInvalidPathChars(String path)
   at System.IO.Path.Combine(String path1, String path2)
   at Microsoft.VisualStudio.Platform.VsAppDomainManager.d__1.MoveNext()
   at Microsoft.VisualStudio.Platform.VsAppDomainManager.InnerResolveHandler(String name)
   at Microsoft.VisualStudio.Platform.VsAppDomainManager.ResolveHandler(Object sender, ResolveEventArgs args)
   at System.AppDomain.OnAssemblyResolveEvent(RuntimeAssembly assembly, String assemblyFullName)
   --- End of inner exception stack trace ---
   at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadBinaryModule(Boolean trySnapInName, String moduleName, String fileName, Assembly assemblyToLoad, String moduleBase, SessionState ss, String prefix, Boolean loadTypes, Boolean loadFormats, Boolean& found)
   at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadModuleNamedInManifest(String moduleName, String moduleBase, Boolean searchModulePath, String prefix, SessionState ss, Boolean loadTypesFiles, Boolean loadFormatFiles, Boolean& found)
   at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadModuleManifest(ExternalScriptInfo scriptInfo, ManifestProcessingFlags manifestProcessingFlags, Version version)
   at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadModule(String fileName, String moduleBase, String prefix, SessionState ss, Boolean& found)
   at Microsoft.PowerShell.Commands.ImportModuleCommand.ProcessRecord()
   at System.Management.Automation.Cmdlet.DoProcessRecord()
   at System.Management.Automation.CommandProcessor.ProcessRecord()
   --- End of inner exception stack trace ---
   at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
   at System.Management.Automation.Runspaces.Pipeline.Invoke()
   at NuGetConsole.Host.PowerShell.Implementation.PowerShellHost.Invoke(String command, Object input, Boolean outputResults)
   at NuGetConsole.Host.PowerShell.Implementation.PowerShellHostExtensions.ImportModule(PowerShellHost host, String modulePath)
   at NuGetConsole.Host.PowerShell.Implementation.PowerShellHost.LoadStartupScripts()
   at NuGetConsole.Host.PowerShell.Implementation.PowerShellHost.Initialize()
   at NuGetConsole.Implementation.Console.ConsoleDispatcher.Start()
   at NuGetConsole.Implementation.PowerConsoleToolWindow.MoveFocus(FrameworkElement consolePane)

Mar 5, 2011 at 9:26 PM

I have the same issue, and have never had Reflector. The only things I have installed are:

- Resharper 5.1.3000.12
- VisualSVN 2.0.5
- VisualHg 1.1.3

However, a workaround seems to be if I start the Package Manager Console prior to opening any project or solution - it will work after that. Very strange.

Mar 5, 2011 at 9:39 PM

Unfortunately this doesn't work either for me.

It's too bad, I've been keeping an eye on NuGet since the first RC but just never had it stable enough to use it.

Developer
Mar 6, 2011 at 5:31 AM

Do you get the exact same exception as above?

Mar 6, 2011 at 9:09 PM

@dfowler

Yes, it appears to be the same, but I have pasted it below. As noted, this occurs if I have an open project _before_ selecting the package console. I stumbled across the successful workaround of opening the console on VS startup - before anything is open - I do not receive this error. Further, I can then use it thereafter when projects are open.

System.Management.Automation.CmdletInvocationException: Could not load file or assembly 'Scripts\nuget.psm1' or one of its dependencies. The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG)) ---> System.IO.FileLoadException: Could not load file or assembly 'Scripts\nuget.psm1' or one of its dependencies. The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG)) ---> System.ArgumentException: Illegal characters in path.

at System.IO.Path.CheckInvalidPathChars(String path)

at System.IO.Path.Combine(String path1, String path2)

at Microsoft.VisualStudio.Platform.VsAppDomainManager.<AssemblyPaths>d__1.MoveNext()

at Microsoft.VisualStudio.Platform.VsAppDomainManager.InnerResolveHandler(String name)

at Microsoft.VisualStudio.Platform.VsAppDomainManager.ResolveHandler(Object sender, ResolveEventArgs args)

at System.AppDomain.OnAssemblyResolveEvent(RuntimeAssembly assembly, String assemblyFullName)

--- End of inner exception stack trace ---

at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadBinaryModule(Boolean trySnapInName, String moduleName, String fileName, Assembly assemblyToLoad, String moduleBase, SessionState ss, String prefix, Boolean loadTypes, Boolean loadFormats, Boolean& found)

at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadModuleNamedInManifest(String moduleName, String moduleBase, Boolean searchModulePath, String prefix, SessionState ss, Boolean loadTypesFiles, Boolean loadFormatFiles, Boolean& found)

at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadModuleManifest(ExternalScriptInfo scriptInfo, ManifestProcessingFlags manifestProcessingFlags, Version version)

at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadModule(String fileName, String moduleBase, String prefix, SessionState ss, Boolean& found)

at Microsoft.PowerShell.Commands.ImportModuleCommand.ProcessRecord()

at System.Management.Automation.Cmdlet.DoProcessRecord()

at System.Management.Automation.CommandProcessor.ProcessRecord()

--- End of inner exception stack trace ---

at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)

at System.Management.Automation.Runspaces.Pipeline.Invoke()

at NuGetConsole.Host.PowerShell.Implementation.PowerShellHost.Invoke(String command, Object input, Boolean outputResults)

at NuGetConsole.Host.PowerShell.Implementation.PowerShellHostExtensions.ImportModule(PowerShellHost host, String modulePath)

at NuGetConsole.Host.PowerShell.Implementation.PowerShellHost.LoadStartupScripts()

at NuGetConsole.Host.PowerShell.Implementation.PowerShellHost.Initialize()

at NuGetConsole.Implementation.Console.ConsoleDispatcher.Start()

at NuGetConsole.Implementation.PowerConsoleToolWindow.MoveFocus(FrameworkElement consolePane)

Developer
Mar 7, 2011 at 3:35 AM

And you have disabled you're extensions? Like the reflector add-in?

Mar 7, 2011 at 6:45 PM

As noted - I do not, nor have I ever had Reflector on this machine. Disabling Resharper 5.1 does nothing to change the above.

That leaves VisualHg as a source control plugin or VisualSVN which a person above already stated they removed and did not 
help as the only remaining items on my machine as far as VS related items.

 

Developer
Mar 7, 2011 at 6:48 PM

Are you sure? I've spoken to people that have said the same thing and they had it installed and didn't know. To be 100% sure open visual studio and go to Tools -> Add-in Manager see if reflector is listed there.

 

Coordinator
Mar 7, 2011 at 6:48 PM

Can you go to the Tools | Add-in Manager in VS and make sure to uncheck *all* options and then click OK. Restart VS and then see if you run into this problem. That'll help us narrow it down.

Mar 7, 2011 at 7:15 PM

I went to Tools -> Add-in Manager and there is nothing listed. Not one thing. I took a screenshot to show but I do not see how to do that here. To disable Resharper I used Tools -> Options -> Resharper -> Suspend 

This is a recently repaved machine with only the items I wrote about on it - very clean. Win 7 Ultimate, VS 2010 Ultimate (No SP1 Beta) and the items I noted.

Mar 7, 2011 at 9:58 PM

Wanted to add, I tested on another machine containing Resharper 5.x and did not have this issue. I have another laptop with Hg + SVN I can try it out on to see if either of those are culprits.

Mar 12, 2011 at 6:08 PM

Looks like my issue got resolved.

I installed SP1 hoping that things would now work.  This was not the case.  I was getting "package could not be loaded" on a bunch of C++ packages.

After googling for a bit, I found a suggestion to run VS with /Setup and /ResetSettings.  I ran both as Admin and reinstalled NuGet and finally it works!

You might want to backup your VS settings first if you customized things like fonts and colors.