Support for PowerGUI 3.5

Jan 29, 2013 at 4:08 PM

I'm using alpha version 1.6.1 and Visual Studio 2012. After upgrade PowerGUI to 3.5 I can't to load extension and my project is no opening anymore. Are there any workarounds for this issue?

Thanks for great tool!

Exception details:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> PowerGui.AddOn.PowerGuiInstallationException: This extension expects version [3.2] of PowerGUI. You currently have version [3.5.0.2293] installed. Please visit PowerGUI.org to download this version of PowerGUI.
   at PowerGui.AddOn.PowerGuiInstallationException.ThrowOnInvalidVersion(Version installedVersion)
   at PowerGuiVsx.Core.PowerGuiAssemblyLoader.GetInstallPath()
   at PowerGuiVsx.Core.PowerGuiAssemblyLoader.get_InstallPath()
   at PowerGuiVsx.Core.PowerGuiAssemblyLoader.LoadAssemblies()
   at PowerGui.AddOn.PowerGuiComposer.Compose(Object obj, Boolean initialize)
   at PowerGUIVsx.UserInterface.InputOutputWindowWrapper..ctor()
   at PowerGUIVsx.InputOutputToolWindow..ctor()
   --- End of inner exception stack trace ---
   at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
   at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
   at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
   at System.Activator.CreateInstance(Type type, Boolean nonPublic)
   at System.Activator.CreateInstance(Type type)
   at Microsoft.VisualStudio.Shell.Package.CreateToolWindow(Type toolWindowType, Int32 id, ProvideToolWindowAttribute tool)
   at Microsoft.VisualStudio.Shell.Package.FindToolWindow(Type toolWindowType, Int32 id, Boolean create, ProvideToolWindowAttribute tool)
   at Microsoft.VisualStudio.Shell.Package.Microsoft.VisualStudio.Shell.Interop.IVsToolWindowFactory.CreateToolWindow(Guid& toolWindowType, UInt32 id)
   at Microsoft.VisualStudio.Platform.WindowManagement.WindowFrame.ConstructContent()

Jan 30, 2013 at 9:10 PM
Edited Jan 30, 2013 at 9:10 PM
I am looking forward to this vs extension being updated to 3.5 eagerly.

Hopefully any changes required are easy to implement.
Coordinator
Feb 12, 2013 at 12:38 AM
Workin on it! Stay tuned.
Feb 21, 2013 at 7:27 AM
In the mean time can you change the link to 3.2 on the homepage from:
to
Would save people a bit of time, thanks
Mar 11, 2013 at 9:21 PM
Adam, any updates?
Would love to have PS support back in VS2012 (worked nicely before we updated to 3.5).
Minor bug was that CTRL-F did not work as expected so could not search for anything.
Developer
Mar 29, 2013 at 4:36 AM
I managed to make this working by downloading the latest source and did a few modifications.
The most important is to search a few Resources.resx files and replace this
<data name="SupportedVersion" xml:space="preserve">
<value>3.2</value>
</data>

to:
<data name="SupportedVersion" xml:space="preserve">
<value>3.5</value>
</data>

These should be the affected files inside: Extension.VS11\ folde
1.PowerGUIExt\PowerGuiVsx.Core\Properties\Resources.resx
2.PowerGUIExt\PowerGui.AddOn\Properties\Resources.resx
3.PowerGUIExt\PowerGui.AddOn.Interfaces\Properties\Resources.resx
4.PowerGUIExt\PowerGui.AddOn.Impl\Properties\Resources.resx


5.PowerGUIExt\PowerGUIExt\source.extension.vsixmanifest
Change
<SupportedFrameworkRuntimeEdition MinVersion="4.0" MaxVersion="4.0" />
to
<SupportedFrameworkRuntimeEdition MinVersion="4.0" MaxVersion="4.5" />
(if you want to use .net framework 4.5 as the target framework)

6.PowerGUIExt\PowerGui.AddOn.Impl\PowerGui.cs
I replaced this method: PSSyntaxEditorControl Debugger_SwitchTabForDebugger(SelectFileArgs arg) to avoid some annoying popup message boxes
    PSSyntaxEditorControl Debugger_SwitchTabForDebugger(SelectFileArgs arg)
    {
    try
        {
            lock (Locker)
            {
                PsControlWrapper editor =
                    _syntaxEditors.FirstOrDefault(
                        m =>
                        string.Equals(m.Document.Filename, arg.FileName, StringComparison.CurrentCultureIgnoreCase));


                return editor;
                // PsControlWrapper cannot be created within this thread. It must have been created before.
                if (editor == null)
                {
                    //throw new Exception("Syntax editor hasn't been created");


                    /*
                    bool isNew = editor == null;
                    if (isNew && arg.OpenIfNotExist)
                        {
                        editor = new PsControlWrapper(this, Debugger, Package);
                        editor.Document.LoadFile(arg.FileName);

                        editor.Disposed += SDisposed;
                        _syntaxEditors.Add(editor);
                        }
                     */
                    return editor;
                }
            }
            //foreach (var n in PowerShellDebugger.Notifies)
            //{
            //   n.ActivateEditor(editor, isNew);
            //}

        }
    catch (Exception ex)
        {
        Log.Error(ex.Message, ex);
        //rad's comment MessageBox.Show(ex.Message, "Error occurred", MessageBoxButtons.OK, MessageBoxIcon.Error);
        return null;
        }
    }

I hope this will help and hopefully I didn't miss anything.

I used this extension to successfully debug installation of complex Nuget package with 50+ dependent nuget packages and I could step line by line.

It is still not polished and hopefully Adam will work on this more. I added a request for highlighting current execution line. Right now you have to look at some Powershell variables to discover where you are in the execution stack.

Regards,
Rad