This project is read-only.
These examples are by no means comprehensive, but they should serve as a general guide for getting around in StudioShell, including finding things, getting help, and using the standard PowerShell cmdlets.

Navigating the DTE drive

This example shows the root of the DTE drive:
C:\PS> ls -path dte:

This example lists all projects in the current solution:
C:\PS> ls -path dte:\solution\projects

This example navigates to the breakpoint node:
C:\PS> cd dte:/debugger/breakpoints

Getting Help

This example gets general StudioShell help:
C:\PS> get-help about_studioshell

This example gets general help for the PSDTE provider that backs the DTE drive:
C:\PS> get-help PSDTE

This example gets help for the out-chart StudioShell cmdlet:
C:\PS> get-help out-chart

This example lists all commands exposed by the StudioShell module:
C:\PS> get-command -module StudioShell

This example gets help for the standard PowerShell cmdlet New-Item as it is used on the projects node:
C:\PS> get-help new-item -path dte:/solution/projects

Standard PowerShell Cmdlets

StudioShell uses the standard PowerShell item cmdlets whenever possible. This section demonstrates how to apply these cmdlets to various nodes in the DTE: drive; for help with specific cmdlets at specific locations, see Getting Help above.

Projects and Items

This example adds a new C# class library project to the current solution:
C:\PS> new-item dte:/solution/projects -name "MyProject" -type classlibrary -language csharp;

This example adds a new C# class to an existing project from the standard class template:
C:\PS> new-item dte:/solution/projects/MyProject -name "MyClass.cs" -type class -language csharp;

This example adds a new folder named Stuff an existing project named MyProject:
C:\PS> new-item dte:/solution/projects/MyProject -name Stuff -type folder

Window Configurations

This example creates a new named window configuration from the current window states:
DTE:\WindowConfigurations> new-item -name "AwesomeWindows"

This example applies a named window configuration to the IDE:
DTE:\WindowConfigurations> invoke-item -name "AwesomeWindows"


This example creates a new breakpoint on the Execute method of MyClass:
C:\PS> new-item -path dte:\debugger\breakpoints -function MyClass.Execute

This example disables all currently defined breakpoints:
C:\PS> dir dte:\debugger\breakpoints | clear-item 

This example enables all currently defined breakpoints:
C:\PS> dir dte:\debugger\breakpoints | invoke-item 

This example deletes all currently defined breakpoints:
C:\PS> dir dte:\debugger\breakpoints | remove-item 


This example creates a command that generates GUID values in PowerShell and puts them on the clipboard. The command can be invoked using the keys CTRL - ALT - G:
C:\PS> new-item dte:/commands -name "CopyGuidToClipboard" -value { [guid]::newGuid().ToString() | clip } -binding "CTRL+ALT+G"

Command Bars

This example creates a new command bar (toolbar) named PSake Stuff and adds a button to it. When the button is clicked, the invoke-psake cmdlet is invoked and its output is sent to an output pane named PSake:
C:\PS> new-item dte:/commandBars -name "PSake Stuff";
C:\PS> new-item "dte:/commandBars/PSake Stuff" -name "Run PSake" -type button -action { invoke-psake | out-outputpane -name PSake }

This example adds an item to the project context menu. The script block specified in the action parameter is executed when the menu item is selected. In this case, when the user clicks the menu item, their StudioShell console will mount the filesystem location where the project resides.
C:\PS> new-item -path "dte:/commandBars/context menus/Project and Solution Context Menus/Project" -name "Mount This Folder" -type button -value { 
                $selectedProjects | select -first 1 | %{ # process the first selected project
		split-path $_.FullName | pushd; # find the directory containing the project and push that location
		write-prompt; # update the console prompt to account for the new location
		invoke-item 'windows:/studioshell'; # set focus to the StudioShell console
	} }


This example adds a warning to the error window:
C:\PS> new-item dte:/errors -value "the cake is a lie!" -type warning


This example displays the contents of the current directory in a grid pane.:
C:\PS> ls | out-grid

This example displays the current stack frame locals in an HTML page:
C:\PS> $currentStackFrame.Locals | out-html

This example displays a bar chart of the number of parameters accepted by each method in the MyProject project:
DTE:\Solution\Projects\MyProject> $allMethods = ls -recurse | where { $_ -match 'method' };
DTE:\Solution\Projects\MyProject> $methodData = $allMethods | select-object Name,@{'Name'='ParameterCount';'Expression'={[int]@($_.Parameters).Count}};
DTE:\Solution\Projects\MyProject> $methodData | out-chart -charttype bar -groupaxis Name -dataaxis ParameterCount

Last edited Nov 11, 2011 at 2:05 AM by beefarino, version 5


No comments yet.