title | description | date |
---|---|---|
Output Window Sample Extension reference |
A reference for Output Window Sample extension |
2022-08-01 |
This extension demonstrates the most basic usage of the Output Window API
Important
The VisualStudio.Extensibility Output window APIs are currently in preview and are subject to change. Any extension that leverages these APIs may fail to work in future versions of Visual Studio and will need to be updated when a newer version of the APIs is released.
This extension adds a command to the Tools menu called "Test the Output Window". When invoked, the command will print "This is a test of the output window."
to the Output pane in a Channel called "MyOutputWindow" (look for the Channel name in the "Show output from:" dropdown in the Output pane).
TestOutputWindowCommand.cs
contains a command that demonstrates two parts of the Output Window API.
The GetOutputWindowAsync()
method creates an Output Window Channel by calling Extensibility.Views().Output.GetChannelAsync()
. GetChannelAsync()
takes the name of a resource from the ResourceManager set up in the Extension
class.
See Getting an Output Window Channel for more information.
In the ExecuteCommandAsync()
method, the Writer
property of the OutputWindow
instance is used to write a message to the Output pane in the IDE.
See Writing to the Output Window for more information.
As described in the Output Window Display Name Resource ID requirements, the current version of the Output Window API requires that the display name for the Output Window Channel be stored in a Resource File (such as a .resx
resource file.)
In order for the call to OutputExtensibility.GetChannelAsync()
to find the display name, the resource file must be associated with the Extension
Instance by overriding the ResourceManager
property.
OutputWindowSampleExtension.cs
demonstrates this functionality.
The Strings.resx
file is a Resource File that contains the display name of the Output Window Channel for this extension.