========== Build: 258 succeeded, 1 failed, 40 up-to-date, 1 skipped ==========
try
{
//Add a command to the Commands collection:
Command command = commands.AddNamedCommand2(_addInInstance,
"BuildStat" ,
"Show failed build parts" ,
"Provides information about failed parts of performed solution build" ,
true ,
56,
ref contextGUIDS,
( int )vsCommandStatus.vsCommandStatusSupported + ( int )vsCommandStatus.vsCommandStatusEnabled,
( int )vsCommandStyle.vsCommandStylePictAndText,
vsCommandControlType.vsCommandControlTypeButton);
//Add a control for the command to the tools menu:
if ((command != null ) && (toolsPopup != null ))
{
command.AddControl(toolsPopup.CommandBar, 1);
}
}
catch (System.ArgumentException)
{
//If we are here, then the exception is probably because a command with that name
// already exists. If so there is no need to recreate the command and we can
// safely ignore the exception.
}
* This source code was highlighted with Source Code Highlighter .
try
{
//Add a command to the Commands collection:
Command command = commands.AddNamedCommand2(_addInInstance,
"BuildStat" ,
"Show failed build parts" ,
"Provides information about failed parts of performed solution build" ,
true ,
56,
ref contextGUIDS,
( int )vsCommandStatus.vsCommandStatusSupported + ( int )vsCommandStatus.vsCommandStatusEnabled,
( int )vsCommandStyle.vsCommandStylePictAndText,
vsCommandControlType.vsCommandControlTypeButton);
//Add a control for the command to the tools menu:
if ((command != null ) && (toolsPopup != null ))
{
command.AddControl(toolsPopup.CommandBar, 1);
}
}
catch (System.ArgumentException)
{
//If we are here, then the exception is probably because a command with that name
// already exists. If so there is no need to recreate the command and we can
// safely ignore the exception.
}
* This source code was highlighted with Source Code Highlighter .
try
{
//Add a command to the Commands collection:
Command command = commands.AddNamedCommand2(_addInInstance,
"BuildStat" ,
"Show failed build parts" ,
"Provides information about failed parts of performed solution build" ,
true ,
56,
ref contextGUIDS,
( int )vsCommandStatus.vsCommandStatusSupported + ( int )vsCommandStatus.vsCommandStatusEnabled,
( int )vsCommandStyle.vsCommandStylePictAndText,
vsCommandControlType.vsCommandControlTypeButton);
//Add a control for the command to the tools menu:
if ((command != null ) && (toolsPopup != null ))
{
command.AddControl(toolsPopup.CommandBar, 1);
}
}
catch (System.ArgumentException)
{
//If we are here, then the exception is probably because a command with that name
// already exists. If so there is no need to recreate the command and we can
// safely ignore the exception.
}
* This source code was highlighted with Source Code Highlighter .
public void Exec( string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled)
{
handled = false ;
if (executeOption == vsCommandExecOption.vsCommandExecOptionDoDefault)
{
if (commandName == "BuildStat.Connect.BuildStat" )
{
handled = true ;
foreach (OutputWindowPane pane in _applicationObject.ToolWindows.OutputWindow.OutputWindowPanes)
{
if (pane.Name == "Build" )
{
//
TextDocument textDocument = pane.TextDocument;
textDocument.Selection.StartOfDocument( false );
textDocument.Selection.EndOfDocument( true );
String buildLog = textDocument.Selection.Text;
if (buildLog.Length > 0)
{
string parsedLog = Parse(buildLog);
if (parsedLog.Length > 0)
Output(parsedLog);
}
break ;
}
}
return ;
}
}
}
* This source code was highlighted with Source Code Highlighter .
public void Exec( string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled)
{
handled = false ;
if (executeOption == vsCommandExecOption.vsCommandExecOptionDoDefault)
{
if (commandName == "BuildStat.Connect.BuildStat" )
{
handled = true ;
foreach (OutputWindowPane pane in _applicationObject.ToolWindows.OutputWindow.OutputWindowPanes)
{
if (pane.Name == "Build" )
{
//
TextDocument textDocument = pane.TextDocument;
textDocument.Selection.StartOfDocument( false );
textDocument.Selection.EndOfDocument( true );
String buildLog = textDocument.Selection.Text;
if (buildLog.Length > 0)
{
string parsedLog = Parse(buildLog);
if (parsedLog.Length > 0)
Output(parsedLog);
}
break ;
}
}
return ;
}
}
}
* This source code was highlighted with Source Code Highlighter .
public void Exec( string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled)
{
handled = false ;
if (executeOption == vsCommandExecOption.vsCommandExecOptionDoDefault)
{
if (commandName == "BuildStat.Connect.BuildStat" )
{
handled = true ;
foreach (OutputWindowPane pane in _applicationObject.ToolWindows.OutputWindow.OutputWindowPanes)
{
if (pane.Name == "Build" )
{
//
TextDocument textDocument = pane.TextDocument;
textDocument.Selection.StartOfDocument( false );
textDocument.Selection.EndOfDocument( true );
String buildLog = textDocument.Selection.Text;
if (buildLog.Length > 0)
{
string parsedLog = Parse(buildLog);
if (parsedLog.Length > 0)
Output(parsedLog);
}
break ;
}
}
return ;
}
}
}
* This source code was highlighted with Source Code Highlighter .
private string Parse( string buildLog)
{
String parseResult = "" ;
StringReader logReader = new StringReader (buildLog);
Regex failedProjects = new Regex( "[1-9][0-9]* error\\(s\\), [0-9]+ warning\\(s\\)" );
for ( string line = logReader.ReadLine(); line != null ; line = logReader.ReadLine())
{
if (failedProjects.IsMatch(line))
{
parseResult += line;
parseResult += "\r\n" ;
}
if ((line.IndexOf( ": error" ) != -1) || (line.IndexOf( ": fatal error" ) != -1))
{
parseResult += line;
parseResult += "\r\n" ;
}
}
return parseResult;
}
* This source code was highlighted with Source Code Highlighter .
private string Parse( string buildLog)
{
String parseResult = "" ;
StringReader logReader = new StringReader (buildLog);
Regex failedProjects = new Regex( "[1-9][0-9]* error\\(s\\), [0-9]+ warning\\(s\\)" );
for ( string line = logReader.ReadLine(); line != null ; line = logReader.ReadLine())
{
if (failedProjects.IsMatch(line))
{
parseResult += line;
parseResult += "\r\n" ;
}
if ((line.IndexOf( ": error" ) != -1) || (line.IndexOf( ": fatal error" ) != -1))
{
parseResult += line;
parseResult += "\r\n" ;
}
}
return parseResult;
}
* This source code was highlighted with Source Code Highlighter .
private string Parse( string buildLog)
{
String parseResult = "" ;
StringReader logReader = new StringReader (buildLog);
Regex failedProjects = new Regex( "[1-9][0-9]* error\\(s\\), [0-9]+ warning\\(s\\)" );
for ( string line = logReader.ReadLine(); line != null ; line = logReader.ReadLine())
{
if (failedProjects.IsMatch(line))
{
parseResult += line;
parseResult += "\r\n" ;
}
if ((line.IndexOf( ": error" ) != -1) || (line.IndexOf( ": fatal error" ) != -1))
{
parseResult += line;
parseResult += "\r\n" ;
}
}
return parseResult;
}
* This source code was highlighted with Source Code Highlighter .
private void Output( string outputString)
{
OutputWindowPane myPane = null ;
foreach (OutputWindowPane pane in _applicationObject.ToolWindows.OutputWindow.OutputWindowPanes)
{
if (pane.Name == "Build [failed]" )
{
myPane = pane;
break ;
}
}
if (myPane == null )
myPane = _applicationObject.ToolWindows.OutputWindow.OutputWindowPanes.Add( "Build [failed]" );
myPane.Clear();
myPane.OutputString(outputString);
myPane.Activate();
}
* This source code was highlighted with Source Code Highlighter .
private void Output( string outputString)
{
OutputWindowPane myPane = null ;
foreach (OutputWindowPane pane in _applicationObject.ToolWindows.OutputWindow.OutputWindowPanes)
{
if (pane.Name == "Build [failed]" )
{
myPane = pane;
break ;
}
}
if (myPane == null )
myPane = _applicationObject.ToolWindows.OutputWindow.OutputWindowPanes.Add( "Build [failed]" );
myPane.Clear();
myPane.OutputString(outputString);
myPane.Activate();
}
* This source code was highlighted with Source Code Highlighter .
private void Output( string outputString)
{
OutputWindowPane myPane = null ;
foreach (OutputWindowPane pane in _applicationObject.ToolWindows.OutputWindow.OutputWindowPanes)
{
if (pane.Name == "Build [failed]" )
{
myPane = pane;
break ;
}
}
if (myPane == null )
myPane = _applicationObject.ToolWindows.OutputWindow.OutputWindowPanes.Add( "Build [failed]" );
myPane.Clear();
myPane.OutputString(outputString);
myPane.Activate();
}
* This source code was highlighted with Source Code Highlighter .
Source: https://habr.com/ru/post/91276/
All Articles