This article is in continuation of “Creating your first visual studio VSIX package” article of the series Visual Studio Extensibility. The first part focused on creating a Visual Studio Extension to locate a file or folder in Windows Explorer, the second part was more about deploying the Visual Studio extension to staging server via continuous integration. This article will illustrate how to add or embed the visual studio extension or visual studio package into a Visual Studio Isolated Shell application. Visual Studio provides the flexibility to create our own IDE or a Visual Studio kind of product altogether having custom extensions or some pre-defined functionalities of visual studio. Therefore one can get their custom Visual Studio as a product which could be sold in the market.
In this article, I’ll explain how one can customize the basic Visual Studio Isolated shell application and add a custom extension to the shell application. Visual Studio can be completely customized from its launch screen to the advanced functionalities which it provides.
Let me again review the roadmap of this series of Visual Studio Extensibility. The series will be divided into three articles as mentioned below, and we’ll focus more on practical implementations and hands-on rather than going much into theory.
- Visual Studio Extensibility (Day 1): Creating your first visual studio VSIX package
- Visual Studio Extensibility (Day 2): Deploying the VSIX package on staging server and GIT via Continuous Integration
- Visual Studio Extensibility (Day 3): Visual Studio extension in Visual Studio Isolated Shell
The prerequisite for this article is a running application that was created in part one or second of this series. The source code for the prior application having a vsix extension could be downloaded along with this article or from Github.
Visual Studio Shell
Visual Studio Shell has two modes, Integrated and Isolated. Following are the definitions for both the modes. One can read more on MSDN.
“Integrated mode enables your users to use standard Visual Studio features along with your custom tools. The integrated shell is intended primarily for hosting programming languages and software development tools.
Custom tools that are built on the integrated shell automatically merge with any other edition of Visual Studio that is installed on the same computer. You can provide a redistributable version of the Visual Studio integrated shell if Visual Studio is not already installed.
The redistributable version of the Visual Studio integrated shell does not include programming languages and the features that support their respective project systems.”
“Isolated mode allows you to create custom tools that run side-by-side with other versions of Visual Studio. It is intended primarily for tools that can access Visual Studio services without depending on all the standard Visual Studio features. You can customize the appearance of applications built on the Visual Studio isolated shell. You can easily turn off the features and menu command groups that you do not wish to appear together with your application.”
Visual Studio Isolated Shell
The definition from MSDN says,
“The Visual Studio isolated shell allows you to create stand-alone applications that can run side-by-side with other versions of Visual Studio. It is used primarily to host specialized tools that can use Visual Studio services but also have a customized appearance and branding. Visual Studio features and menu command groups can be easily turned on and off. Application titles, application icons, and splash screens are fully customizable.” Read more…
Like I described at the start of the article that using Visual Studio Isolated Shell, you can create/customize Visual Studio like product. There is a lot of theory around this which could be read over the internet on MSDN. This article will focus on creating a simple Visual Studio Isolated Shell application and integrating the pre-developed extension into it as the complete theory part is beyond the scope of this article.
Create Isolated Shell Application
Step 1 (Create new project)
Open Visual Studio 2015 and go to File->New->Project.
Step 2 (Choose Isolated Shell)
Step 3 (Get the solution)
Basic Isolated Shell Solution Structure ShellApplication Project
This is the main project responsible for customized appearance of isolated shell application, all the customizations and actions could be controlled from this projects. This project contains the folder named ShellCustomization which allows on how the application would look like, what should be the start / launch screen and what features we can enable or disable from the existing visual studio features. One can do this by customizing pkgdef or pkgundef file. Read more about customization..
This is a VSIX package project that helps us to customize Help\Aboutbox section. One can provide description, copyright information of the product here.
Basically modify the “About” section as per your need and desire.
This is a small simple project containing a single file named “source.extension.vsixmanifest”. This file holds reference of various components and modules that are to be used in Isolated shell application. So, whatever VS Extensions or VSIX projects are added in isolated shell application, their reference is added in the shellextensionvsix project and specified in Assets section of the file like Aboutbox package is specified in the following image.
This is a C++ project that creates a satellite assembly having commands and resource strings that are localizable.
Customize Visual Studio Isolated Shell Application
Now, we have the solution structure created and we can customize the application as per our need.
In the ShellCustomization folder of ShellApplication project, open the ShellApplication.Application.pkgdef file. We can see the available settings in the file in the form of key value pairs. SplashScreenBitmap setting, as shown in the below image, is used to define the default image file that shows up when the application is launched. The default is a white image with a text at bottom that says “Powered by Visual Studio”. One can change this image as per the product’s main launch image. It takes path to Splash.bmp file in the root folder. Replace that Splash.bmp file with a custom image file.
As mentioned earlier, one can also customize the AboutBox package responsible to show information in Help\About when the application launches. In the ShellApplication.AboutBoxPackage, open the source.extension.vsixmanifest file. Since this project is VSIX project type, one can see the VSCT extension and the command files in the project like earlier used in the find in explorer project created in first part of this series. In the vsixmanifest file, specify the Author, version of the product, product name, description and language of the product in Metadata section. All this information will be shown when user clicks on Help\About button in Isolated Shell application.
Right click vsixmanifest file and in the context menu, click on Auto-sync Resx and Icon file, to sync the resx file with the manifest file as shown in the following image. This step is also described in detail in first part of the series.
Now, since we have synced the .resx and icon files, the redundant VSPackage.resx file makes no sense and can be deleted from the application as shown in following image. We can see that the manifest file now has its own .resx file and .cs file underneath the source.extension.vsixmanifest file.
Modify the assembly info of the AboutBoxPackage as per your need. AssemblyInfo.cs file is located under Properties inside ShellApplication.AboutBoxPackage project.
Launch Visual Studio Isolated shell application
We are good to launch our basic Isolated shell application and see what we get. Compile the solution and press F5 to run the application. When the application starts, the custom image we used as Splash screen will be shown as shown below.
After which the application launches. We see another visual studio kind of application with a custom small icon at the top and AppName that was specified in manifest file in ShellApplication pkgdef file.
So, we get our custom application similar to that of visual studio. Add VSIX Extension into Isolated Shell Application
One can add a new VSIX package as an extension or add an already developed extension inside isolated shell application so that the extension becomes the part of the product. We’ll add an already created LocateFolder extension to this isolated shell application. This requires few simple steps.
Right click on the solution explorer of Isolated shell application and choose an option to add an existing project. We need to add existing locate folder project to this solution.
Once the project is added, the solution explorer will look like as shown in below image.
Now we need to compile this project and add the reference to the ShellExtensionsVSIX project. Remember? This project contains a manifest file where all the extensions are mentioned.
Right click on References and add a reference to the LocateFolder project.
Now open the source.extension.vsixmanifest file. In the Assets section we can see an already specified AboutBox package.
In the similar way, we need to add the LocateFolder project as well. So click on New button. A new window will be opened to add the new asset as shown below. Select the Type as Microsoft.VisualStudio.VsPackage, and Source as “A project in current solution” (because we have added the LocateFolder project as an existing project in our solution).
Next, choose the project; in this case it is LocateFolder as shown in below image and click OK.
Once done, the project will be added in the assets list and all the related nugget packages required will be restored.
Now compile the application.
Test the application
The only part left is to check if the locate folder extension is actually embedded within isolated shell application or not. So just run the application. The splash screen will be launched.
When Isolated shell application opens up, create a new project via File->New->Project.
Choose a blank solution, give it a name of choice.
Add a new or existing file in that solution.
Now right click on the file to check if the “Open in file explorer extension is present or not”.
One will get to see the Open in File Explorer extension shown on the context menu of the file as it used to display in the experimental instance in the first part. This proves that the extension is successfully embedded in Visual Studio Isolated Shell application. Now, one can test the extension by actually clicking on the command, and it will open the file location with the file selected.
This article explained how we can create a simple Visual Studio Isolated Shell application. With this power of Visual Studio, one can create a new product altogether or a new IDE altogether and leverage the inbuilt functionalities of Visual Studio as well. The “Good Read” and “Reference” sections of this article are important if one wants to explore Isolated shell application in more detail.
Complete Source Code
Extension at marketplace