Live Chat Icon For mobile
Live Chat Icon
Popular Categories.NET  (150).NET Core  (25)Angular  (46)ASP.NET  (48)ASP.NET Core  (60)ASP.NET MVC  (84)Azure  (28)Blazor  (84)DocIO  (19)Essential JS 2  (68)Essential Studio  (162)Flutter  (97)JavaScript  (146)Microsoft  (101)PDF  (57)React  (32)Succinctly series  (120)Syncfusion  (464)TypeScript  (30)Uno Platform  (2)UWP  (4)Vue  (26)Webinar  (21)Windows Forms  (54)WPF  (112)Xamarin  (124)XlsIO  (24)Other CategoriesBarcode  (4)BI  (29)Bold BI  (3)Build conference  (6)Business intelligence  (53)Button  (4)C#  (105)Chart  (48)Cloud  (9)Company  (445)Dashboard  (6)Data Science  (3)Data Validation  (3)DataGrid  (41)Development  (247)Doc  (7)DockingManager  (1)eBook  (91)Enterprise  (22)Entity Framework  (5)Essential Tools  (14)Excel  (19)Extensions  (12)File Manager  (4)Gantt  (8)Gauge  (6)Git  (4)Grid  (26)HTML  (9)Installer  (2)Knockout  (2)LINQPad  (1)Linux  (1)M-Commerce  (1)Metro Studio  (11)Mobile  (205)Mobile MVC  (9)OLAP server  (1)Open source  (1)Orubase  (12)Partners  (21)PDF viewer  (21)Performance  (4)PHP  (1)PivotGrid  (4)Predictive Analytics  (6)Report Server  (3)Reporting  (10)Reporting / Back Office  (11)Rich Text Editor  (5)Road Map  (9)Scheduler  (22)SfDataGrid  (8)Silverlight  (21)Sneak Peek  (16)Solution Services  (2)Spreadsheet  (7)SQL  (6)Stock Chart  (1)Surface  (4)Tablets  (5)Theme  (9)Tips and Tricks  (52)UI  (113)Uncategorized  (68)Unix  (2)User interface  (68)Visual State Manager  (1)Visual Studio  (18)Visual Studio Code  (10)Web  (187)What's new  (120)Windows 8  (19)Windows App  (1)Windows Phone  (15)Windows Phone 7  (9)WinRT  (26)
Share on twitter
Share on facebook
Share on linkedin
Creating Visual Studio for Mac Extensions: A Complete Guide

Creating Visual Studio for Mac Extensions: A Complete Guide

Extensions are an indispensable part of project development. They play a vital role in improving developer productivity by providing customization, easing development, and much more.

Visual Studio for Mac extensions are add-ons that enhance productivity and allow you to customize your project by adding new features or integrating existing tools into it. These extensions can customize both existing and new projects by adding files, new dialogs, menus, commands, and so on.

This blog post explains the procedure to create extensions for Visual Studio for Mac that can be configured to create a Visual Studio for Mac project template and extensions menu.

Prerequisites

Create IDE Extension project using AddinMaker

  1. Open Visual Studio for Mac.
  2. To install the AddinMaker extension package, from the Visual Studio menu, Choose Extensions….
    Choose Extensions….
  3. In the Extension Manger window, navigate to the Gallery tab and type Addin Maker into the top-right search bar. Select Addin Maker from the Addin Development category and click Install.
    Navigate to the Gallery tab and type Addin Maker into the top-right search bar. Then, select Addin Maker.
  4. Now, AddinMaker is installed, and you can start building your own extension project. Let’s start by creating a new solution.
  5. From the new project creation dialog, choose Other > IDE Extensions > General > IDE Extension > C# and click Next.
    choose Other > IDE Extensions > General > IDE Extension > C# and click Next.
  6. Name the project, choose the destination path of the project, and click Create. Visual Studio for Mac will populate the created project. Here we are going to create a Xamarin IDE extension project.
    Solution explorer window showing the created project

Update the extension details

  1. Create the extension project template configuration file by right-clicking on the project and choosing Add > New File > File Template and name the file. Then, click the New button. The file will be added in your project.
    Right-click on the project and choose Add > New File > File Template and name the file
  2. The created template configuration file will be added as {GivenFileName.xft.xml}. Now, change the file extension type as xpt.xml from xft.xml {GivenFileName.xpt.xml}.
  3. In the template configuration file, update the name, category, language name, default file name, icon, description, and parameter details within the tag in the template configuration section.Refer to the following code.
    <TemplateConfiguration>
            <_Name>Name of the Template</_Name>
            <Category>Category</Category>
            <LanguageName>Language Name</LanguageName>
            <DefaultFileName>Default File Name</DefaultFileName>
            <Icon>Icon of the template </Icon>
            <Image file="image file location" />
            <_Description>Description of template</_Description>
            <DefaultParameters>Parameter Details</DefaultParameters>
    </TemplateConfiguration>

Configure the template configuration file

Now, configure the template configuration file in the Manifest.addin.xml file as seen in the following screenshot.
Configure the template configuration file in the Manifest.addin.xml file

Configure the project and add files in the template configuration file

Configure the project section in the template configuration file as shown in the following screenshot.
Configure the project section in the template configuration file

  1. Here, ${ProjectName} was replaced by the name mentioned in the project creation dialog.
  2. Add the reference by using the Reference tag. If you want to refer to an assembly, then provide the type as GAC. If you are referring to another project, then give the type as project and mention the project name in the refto attribute.
  3. To add the file in the directory, add the file tag between the directory tags. If you want to add the file in the project directory, add the file tag between the File tags.

Include the template files in the extension addin

Now, include the file path in the Import tag between the Runtime tags in the ManiFestaddin.xml file, as seen in the following screenshot.
Include the file path in the Import tag between the Runtime tags in the ManiFestaddin.xml file

Customize the project template from the extension menu

You can customize the project template from the extension menu. To do so, follow these steps:

  1. Add a new class file and make the following content in the file content.
  2. In the Run method, provide the Name that you mentioned in the template configuration XML file in the bracket.Refer to the following screenshot.
    In the Run method, provide the Name that you mentioned in the template configuration XML file in the bracket
  3. Call the above command from Manifestaddin.xml. You should mention the command id({Namespace}.{CommandID}.{Command}) in the command item id. Here, we have named it as MyXamarinProjectTemplate.MyXamarinCommands.CreateNewProject.
    Mention the command id({Namespace}.{CommandID}.{Command}) in the command item id

Change MacExtensions’ name and version

Change the MacExtensions name and version details after creating the entire project in the AddinInfo.cs file. Please refer to the following screenshot.
Change the MacExtensions name and version details after creating the entire project in the AddinInfo.cs file

Install the extension

  1. You can find the extension in the output location with the extension name *.mpack, like the following screenshot.
    You can find the extension in the output location with the extension name *.mpack
  2. Click on the Visual Studio menu and select Extensions….
    Click on the Visual Studio menu and select Extensions….
  3. The Extension Manager window will open. Click the Install from file… button.
    Extension Manager window
  4. The Install Extension Package dialog will open. Navigate to your Mac extensions file (.mpack) location and click open to install. The extensions will be installed into your project.Refer to the following screenshot.
    Install Extension Package dialog

Run the extensions

Run the sample extension in the Visual Studio Mac instance. This will open another Visual Studio for Mac instance that will show the template in the project template wizard and Visual Studio menu.

Project template wizard

In the new instance of Visual Studio 2019 for Mac, click on the New button.
click on the New button

Then, in the project template wizard, you can find the template My Xamarin Project Template under Multiplatform > App.
In the project template wizard, you can find the template My Xamarin Project Template under Multiplatform > App

Visual Studio for Mac menu

You can also find the given menu name (which is mentioned in the ItemSet ID tag in Manifestaddin.xml file) in the Visual Studio menu.
Visual Studio for Mac menu

Source of this sample extension

You can download the complete source code for this sample extension from https://www.syncfusion.com/downloads/support/directtrac/general/ze/MacExtensions266839071.

Conclusion

I hope this article was useful in showing every step in creating extensions for a project template in the Visual Studio for Mac project template wizard and extension menu.

Syncfusion has about 1,600 components and frameworks for WinFormsWPF, WinUI(Preview), ASP.NET (Web FormsMVCCore), UWPXamarinFlutterJavaScriptAngularBlazorVue, and React. Use them to boost your application development speed.

If you have any questions, please let us know in the comments section. You can also contact us through our support forumDirect-Trac, or feedback portal. As always, we are happy to assist you!

If you like this post, we think you would also like the following articles too:

Tags:

Share this post:

Share on twitter
Share on facebook
Share on linkedin

Comments (2)

Thanks for this.

Hi
One important information is you should share I that Microsoft has closed the registration of new accounts on the “extension store” for Mac so if you create a plugins you will not be able to publish it.

regards Joacim Wall

Comments are closed.

Popular Now

Be the first to get updates

Subscribe RSS feed
Scroll To Top