Automatically Loading VSIX Packages

So you’re creating a VSIX package that does not have a menu items, tool windows or command? But still you want the package to get loaded (i.e. executed) by the IDE? What a crazy thing to wish for, one might think after spending hours searching the internet on how to do that. But don’t abandon hope, yet, since the answer is nigh.Read More »

Resolve Visual Studio Macros In VSIX Packages Or T4 Templates

We all love Visual Studio Macros, right? Pre- and Post-Build actions or MSBuild scripts would get very nasty if there were no macros like “ProjectDir”, “ConfigurationName” or “OutDir”. If these macros are so useful, then why not make use of them in your own VSIX packages or T4 templates? If your answer is “because I got lost in the maze of Visual Studio’s object model and it’s too dark to see” then fear not! You will find your way out very soon. Read More »

Write To Visual Studio’s Output Window

If you have developed a Visual Studio Extension, you might want to output messages to Visual Studio’s Output window. Here’s how to do it:

using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;

namespace MunirHusseini.Demos
{
    public class VsOutput
    {
        public static void Output(string msg)
        {
            // Get the output window
            var outputWindow = Package.GetGlobalService(typeof(SVsOutputWindow)) as IVsOutputWindow;

            // Ensure that the desired pane is visible
            var paneGuid = Microsoft.VisualStudio.VSConstants.OutputWindowPaneGuid.GeneralPane_guid;
            IVsOutputWindowPane pane;
            outputWindow.CreatePane(paneGuid, "General", 1, 0);
            outputWindow.GetPane(paneGuid, out pane);

            // Output the message
            pane.OutputString(msg);
        }
    }
}

Of course, you could output to other panels than just “General”. To do that, just change the value of the variable paneGuid. Possible values are:

BuildOutputPane_guid The build output pane inside the output window.
DebugPane_guid The debug pane inside the output window.
GeneralPane_guid The general output pane inside the output window.
SortedBuildOutputPane_guid The sorted build output pane inside the output window.
StoreValidationPane_guid The store validation pane inside the output window.

For a visual demonstration, please watch this video.

Manually Applying XML Document Transform (XDT)

There might be situations where you might want to execute XDT of a web.config or app.config “manually” (i.e. apply the transformation in your code instead of letting not Visual Studio do the work). For example, this might be necessary when you want to examine the web.config or app.config file from within a Visual Studio extension. Fortunately, this is quite easy.
Read More »