How to access project properties from PowerShell?

Jun 27, 2011 at 10:05 AM

Hi

Thanks for the great piece of software! Although it still have some bugs (shift-home, shift-end, shift-insert does not work, scrolling sometimes behaves weird), they looks to be minor and easily fixable.

I did some Visual Studio automation with IronPython recently, but it looks like PowerShell is more suitable for the task, especially when it comes to executing one-liners. So I decided to learn PowerShell and started from porting my IronPython scripts.

I have a python line which gets access to command line of an nmake project.

dte.Solution.Projects.Item(1).Object.Configurations.Item(1).Tools.Item('VCNMakeTool').BuildCommandLine

it works with Python, but not with PowerShell:

� DTE:\solution\projects>$dte.Solution.Projects.Item(1).Object.Configurations.Item(1).Tools.Item('VCNMakeTool')
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')
    + CategoryInfo          : InvalidOperation: (Item:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

Why does it happen and how to work around of it?

Thanks again.