The idea is excellent, the execution leaves a bit to be desired. First, there seems to be zero support for profiles... i.e. this isn't a true PowerShell host environment. When started, no profile scripts are run. Worse, I received several errors. Despite this, we do have a working PowerShell prompt within Visual Studio, which is just what I wanted. The integration with various services and variables giving you access to the IDE within the prompt is wonderful. Unfortunately, not being a real PowerShell host environment continues to rear it's ugly head. Remember when I said profiles aren't run? Well, that means my customizations aren't applied. Most importantly, this means various modules I really on (like PSCX) aren't loaded. So, I try load one (specifically PSCX), and it fails. I can't load any modules successfully, meaning I'm in a very crippled PowerShell environment. Unless/until these issues are fixed, I won't be using this extension. :(
Is there a way to get this to run inside VS11? Currently if I search for PowerConsole within the VS11 Beta extension manager (in Online Extensions) there aren't any matches.
For some other extensions, just modifying the build to change the supported versions to include 11 was all that was needed, and I'm guessing that's the case here, too?
Thanks!
FWIW, I confirmed that just adding VS11 as supported was sufficient (at least for a simple case of trying File.NewProject)
http://blog.sublogic.com/2012/04/11/getting-your-favorite-visual-studio-2010-extension-to-run-in-visual-studio-11/
Great extension... it's very handy to have PowerShell right there in studio, especially with access to $dte.
I find though, that when executing a long running command, the whole of studio hangs until the command has finished. As I use a few external build / test scripts it would be good to be able to continue working while commands are running.
Is there a workaround for this?
It has this problem because of a bug in .NET. Implementing it in async pattern could easily hang Visual Studio. Sorry I don't know of easy workaround. You can probably try PowerShell's job facility for some scenarios.
Hi
Thanks for providing a handy tool to control Visual Studio from command line. I wrote a couple of scripts in IronPython but decided to switch to PowerShell because it is better for executing one-line commands.
I found that PowerShell lacks some IronPython's abilities of control VisualStudio when it comes to deal with COM-objects.
Have a look:
py> dte.Solution.Projects.Item(1).Object.Configurations
<Microsoft.VisualStudio.Project.VisualC.VCProjectEngine.VCCollectionShim object at 0x000000000000002E [Microsoft.VisualStudio.Project.VisualC.VCProjectEngine.VCCollectionShim]>
py> [x.Name for x in dte.Solution.Projects.Item(1).Object.Configurations]
['Debug|Win32', 'Release|Win32']
py> dte.Solution.Projects.Item(1).Object.Configurations.Item(1).Tools.Item('VCNMakeTool').BuildCommandLine
'scons -j9 --arch=amd64'
But nothing in PowerShell
PS> $dte.Solution.Projects.Item(1).Object.Configurations
PS>
PS> $dte.Solution.Projects.Item(1).Object.Configurations.Item(1).Tools.Item('VCNMakeTool').BuildCommandLine
You cannot call a method on a null-valued expression.
At line:1 char:58
+ $dte.Solution.Projects.Item(1).Object.Configurations.Item <<<< (1).Tools.Item('VCNMakeTool').BuildCommandLine
+ CategoryInfo : InvalidOperation: (Item:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
How to access the project configuration from PowerShell ?
Thanks.
Hi Zheng Xi,
Sorry to reply late. I have also seen that PowerShell has problems interacting with COM. I have built in a small utility "Get-Interface". Probably you can work around using this utility.
PS> $dte.Solution.Projects.Item(1).Object
format-default : The field/property: "project" for type: "Microsoft.VisualStudio.Project.VisualC.VCProjectEngine.VCProjectShim" differs only in case from the field/property: "Project". Failed to use non CLS complia
nt type.
PS> $p = Get-Interface $dte.Solution.Projects.Item(1).Object ([Microsoft.VisualStudio.VCProjectEngine.VCProject])
PS> $p.Configurations | %{ $_.Name }
Debug|Win32
Release|Win32
I don't know much about the project system / interfaces. Hope you can work around with the above.
Thanks
Great product - it may be the best PS shell I've seen (compared to PoSH, the ISE and powershell.exe). Any way to run it outside of Studio? I presume the command line interpreter is bolted onto Studio, so probably not.
Thanks! The major problem is that it depends on VS editor components, so can't run outside of VS (unless we package with a copy of VS editor, which involves other problems).
Don't know what happened... Yes, it is supposed to have intellisense through Tab expansion. Did you get any error message logged in the window? Did you customize PowerShell function "TabExpansion"?
Just in case: The intellisense works the same way as in PowerShell console. You have to type part of something existing and then pressing Tab will complete it for you.
Anyway to change the font color? Since my boxes are black with the background i cant the text on it. I couldn't seem to find where to the font color for power console though.
It uses font settings combined from CommandWindow and TextEditor. You can change them in Tools->Options, Environment, Fonts And Colors, Show settings for "Command Window" and "Text Editor".
Is there any chance we could get the source of this extension? It's nice, but I'd like to extend it a bit, and it would be a good way to pick up some of the new vs2010 stuff :)
Another vote!
Since extension is free, will be nice to see it's code on CodePlex!
It will allow extending/modifying it and will serve as another good sample of VS extensibility...
Thanks for interests in its source code! To be honest, its source code may not be the best example. There are some other blockers for this idea. We'll reevaluate if it is ok.
Hello,
We're missing few important things for us, like custom prompts...
Do you have a kind of roadmap for this extension? Is "full compatibility" with PowerShell planned? When?
Are you planning releasing it's source code, for example on codeplex?
Thanks!
Yes, it misses features due to time constraint. It may never be fully compatible with official PowerShell; we'll try to improve it based on feedback and priority.
First - thank you! I feel this will become a huge help moving forward. I was wondering though...
1. How can one launch an application from powershell to outside of VS? For example if I want to do "calc" command from the PS prompt, how can I get the calculator to show on my desktop? It seems to be run under the devenv.exe and not accessible and must be killed via task manager.
2. How can we change the color schema? I don't see anything under tools>options in visual studio. Where might I find that option?
Thanks again.
EDIT: "calc" command was a bad example; try to launch "cmd.exe" instead to see what I mean. Any application launched from the command line you can't get access to. e.g. "cmd.exe /c calc" <- this works from cmd.exe but not from PS inside visual studio (it's just an example, I wouldn't normally do that), or "edit c:\boot.ini", etc.
1. It doesn't fully integrate with console I/O and does not work for cmd.exe. "calc" or "cmd /c calc" seems works for me.
2. The color scheme inherits Command Window. It doesn't have its own customization yet.