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. :(
Can either a VS2012 version be published (ideally available in the VS2012 Extensions like it was in VS2010) or the project opened up so others of us can help add the VS2012 support to it?
Thanks!
I've had a discussion with NuGet team. NuGet forked this extension and supports the same functionality across all VS versions including Express SKUs. Please try out NuGet and see if that meets your needs.
Thanks
I just stumbled upon this post, and was wondering, where would I find this NuGet Powershell Console extension? I cant seem to find it in the package manager inside VS 2012, or on the gallery site.
I would love to have this extension working in VS 2012, due to the lack of VB-Macro support.
VS 2012 might have changed some names. If you have Tools -> Library Package Manager -> Package Manager Console, that is the NuGet Powershell console.
Otherwise, go to Tools -> Extensions and Updates... -> Online and search for NuGet.
The last time I used PowerConsole, I was able to paste in a multi-line statements and it worked great. Now, with VS2012 and PowerShell 3.0 installed (not sure if it's the 3.0 install that caused this change or something in VS2012 RTM), when I try to paste in a multi-line statement, it no longer waits for the end of the block, but fails on parsing immediately.
Somewhat scary, it fails even if I provide what I believe to be the line continuation character (backtick) at the end of the line
For instance (snipping some of the error text to fit into the 2000 character limit)
PS> $PSVersionTable
Name Value
---- -----
PSVersion 3.0
WSManStackVersion 3.0
SerializationVersion 1.1.0.1
CLRVersion 4.0.30319.17929
PS> foreach ($project in $dte.Solution) {
Missing closing '}' in statement block.
PS> foreach ($project in $dte.Solution) `
At line:1 char:36
+ foreach ($project in $dte.Solution) `
+ ~
Missing statement body in foreach loop.
PS> function foo {
Missing closing '}' in statement block.
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.
Xu, thanks a lot for the extension.
I was wanting to use it to publish a project but I get an error when I run the command below in the ouput window. Any suggestions.
Command:
$sb.PublishProject('Release|Mixed Platforms', 'C:\NEOv2\NEOv2\NEOv2.csproj', $false)
Error(in output window):
Error: Object reference not set to an instance of an object.
========== Publish: 0 succeeded, 0 failed, 0 skipped ==========
P.S.
This command works:
$sb.BuildProject('Release|Mixed Platforms', 'C:\NEOv2\NEOv2\NEOv2.csproj', $false)
This control is quite good, I also do a same form to get powershell's stdout .
in c# I used process class to create powershell.exe
but when I read stdout, I couldn't read anything but 'Windows PowerShell
Copyright (C) 2009 Microsoft Corporation. All rights reserved.'
I don't understand what is wrong, do you? Thanks...
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).