Table of Contents
This article is the continuation of the article "Creating your first Visual Studio VSIX package" in this series on 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 revise 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): Embedding VSIX package in Visual Studio Isolated Shell
The prerequisite for this article is a running application that was created in part one 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. The 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 the 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, you can use Visual Studio Isolated shell to create/customize Visual Studio like a product. There is a lot of theory around this which could be read in various places online like 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, go to File->New->Project
Step 2(Choose Isolated shell): In the installed project templates, expand the node for Other Project Types and choose Extensibility as project type. Choose Visual Studio Isolated Shell from the available templates under Extensibility and give the application a name. For example, ShellApplication as shown in below image. Extensibility project types will only be available if you have extensibility features on while installing Visual Studio 2015, you can also modify Visual Studio installation to make these features available. This is explained in first part of the series.
Step 3(Get the solution): When "OK" button is clicked, Visual Studio installs the necessary nugget packages and creates a solution with the same name as given earlier and this solution contains four projects. This is the basic structure of Isolated shell application and could be extended as per requirements. In the main editor screen one can see the page containing all the information and link to good Visual Studio isolated shell articles on MSDN.
Basic Isolated Shell Solution Structure
This is the main project responsible for a customized appearance of isolated shell application. All the customizations and actions could be controlled from this project. 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 "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 a reference of various components and modules that are to be used in Isolated shell application. So whatever Visual Studio extensions or VSIX projects are added in isolated shell application, their reference is added in the shellextensionvsix project and specified in the Assets section of the file like Aboutbox package is specified in 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 the 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 defalt is a white image with text at the 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. Since I’ll illustrate how to integrate search file extension, I have created a custom launch screen file with search image. Likewise, replace the ApplicationIcon and application small icon in the Resource Files folder, the settings of these are mentioned by the name AppIcon in the pkdef file. Change the AppName in the pkgdef file (for example, the name of your application/product). One can do more customizations by changing the values for the keys present in the pkgdef file as per our need like DefaultHomePage, DefaultSearchPage etc.
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 the 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 y=the Icon file to sync the resx file with the manifest file as shown in 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. The AssemblyInfo.cs file is located under Properties inside the 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 the isolated shell application so that the extension becomes 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 as shown in the 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 a 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 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 on 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 and leverage the inbuilt functionalities of Visual Studio as well. The "Good Read" and "Reference" section of this article are important if one wants to explore Isolated shell application in more detail.
Complete Source Code
Extension at marketplace