Using Templates Visual Studio For Mac

In the first part of this set of posts I looked at creating a dotnet new project template, and in the second part I showed how you could easily add this to a Visual Studio for Windows extension. Lets now look at adding it to a Visual Studio for Mac extension, so that our template is available everywhere.

The provides a way to create a project template from an existing project or solution open in Visual Studio for Mac and have the project template available in the New Project dialog straight away. The Template Creator uses the to create the projects from the project templates. Let us take a look in more detail at what the Template Creator extension provides in Visual Studio for Mac. Features • Create a project template from an existing solution or project • Create custom top level project template categories Supports • Visual Studio Mac 7.0 or later. Creating a new Project Template To create a new project template for a project opened in Visual Studio for Mac, right click the project and select Create Template.

A Template Information dialog is then opened. The information in the dialog is used to populate the generated template.json file. Further details on what the template.json file holds is available in the ].

• Author • Author of the project template. • Display Name • This is the template name displayed in the New Project dialog. • Description • This is the description displayed in the New Project dialog.

• Category • This is the category in the New Project dialog used by the template. How to add reference visual studio for mac. • Short Name • This is the short name for the template that can be used from the.NET Core command line.

• Default Project Name • This is the default project name that will be used with the.NET Core command line. • Identity • This is the unique id for the template. This should be unique across all custom project templates. • Group Identity • This is typically a substring of the template’s Identity. By default the project template will use the Other –.NET – General category in the New Project dialog. Mac os emulator on windows. To change the category click the browse button next to the category text box to open the Template Categories dialog.

Select the required category and click OK. The selected category will then be updated in the Template Information dialog.

Click OK to generate the template.json file. The template.json file will be opened in the text editor. It will also be displayed in the Solution window in the.template.config folder. The project template is now available in the New Project dialog. Updating a Project Template After the project template is created you can modify the original project and its template.json file as required. Changes made to the project are available in the New Project dialog immediately. Changes made to the template.json file are available immediately in the same instance of Visual Studio for Mac where the template.json file is being edited.

Multiple Projects in a Template A project template may create more than one project. To create a project template for all projects in the solution right click the solution and select Create Template. A template.json file will be created in a.template.config directory inside the solution’s directory. Note that in order for the new projects created to use the name specified in the New Project dialog they should all have a common start to their name. The template.json file’s sourceName will be the part that is replaced with the name of the project specified in the New Project dialog. Configuring Registered Project Templates The.NET Core templating engine supports project templates in NuGet packages or project templates that unpackaged in a directory.