Project templates in Rider 2017.3

Since the first Rider 2017.3 EAP build a few weeks back, we’ve made a number of incremental changes and improvements to project templates in Rider.

When creating a new solution or project, Rider gives us a number of templates by default:
New project templates in Rider

Instead of grouping templates by language, Rider now groups project templates by framework. This reduces the length of the list of project templates and makes it easier to find what we are after. Rider comes with templates for .NET, .NET Core (if installed on our system) and Xamarin. For every framework, we can specify a series of options:

  • Solution/project name and folder
  • An option to create a Git or Mercurial repository
  • The language to use — many templates support C#, VB.NET and/or F#
  • The target framework that will be used — anything from .NET 3.5 to .NET 4.7, netstandard2.0, netcoreapp2.0, … Note that for a framework to be available from this list, it has to be installed on our system.
  • For Unity and Xamarin, several other options can be provided as well, for example the path to UnityEngine.dll, the target platform (Android or iOS), the type of app (blank, Android Wear, …) Note that these options, too, depend on available frameworks on our system, such as the MonoAndroid versions installed.

The New Project window is now also searchable. For example we can search for a type of application, or an available programming language. Rider will filter the list for us:
Search through installed project templates

Installing additional project templates

Earlier versions of Rider already made it possible to install additional project templates, however this was kind of cumbersome   one needed to create a plugin. With Rider 2017.3, installing additional project templates is easy! We now leverage the template system that is used by the .NET tooling   dotnet new.

The dotnet new command makes use of special NuGet packages to distribute project templates, making it very straightforward to create and share them. Lots of projects already have published project templates to the dotnet templates gallery: Akka.NET, Cake build, Microsoft Azure IoT, IdentityServer, NancyFX, NServiceBus, Auth0, Fable, …

Installing additional templates using dotnet new

The easiest way to install a template is by using the dotnet command line and invoking the install command that is shown in the dotnet templates gallery. Let’s add the IdentityServer4 templates to Rider – by invoking dotnet new --install "IdentityServer4.Templates".
Using dotnet new with Rider to install project templates

Once finished, .NET will display a list of all available templates that we can use from the command line. When re-opening the Rider new solution/new project menu, we will also see the newly installed templates are now available to work with:
IdentityServer4 templates in Rider

Note that the option to select the project language (C#, VB.NET or F#) depends on the languages that are supported by the project template.

Installing additional templates from the Rider UI

Custom project templates can also be installed from the Rider UI. This makes it easier to test templates you are creating (learn more about creating custom templates), or to install templates that are not available publicly.

As an example, I created an Async Main Console application (.nupkg file) project template, which comes with a C# 7 async main method as the default application entry point. From the More Templates tab, we can install or remove custom templates.
Install custom project template

After clicking Reload, Rider makes the project template available for use, making it possible to create a console application that comes with an async main method.

Go on, learn more about creating custom templates and distribute your own templates for use with Rider!

Give Rider 2017.3 EAP a try! We’d love to hear your thoughts and comments.

About Maarten Balliauw

Maarten Balliauw is a Developer Advocate at JetBrains, working on .NET tools. He focuses on .NET, Azure, web technologies and application performance. Maarten is a frequent speaker at various national and international events. In his free time, he brews his own beer. Follow him on Twitter or check his personal blog.
This entry was posted in How-To's and tagged , , , , , , , . Bookmark the permalink.

8 Responses to Project templates in Rider 2017.3

  1. Netta Ben Ezri says:

    I’ve been trying to find out how to make and host a website(I thought to host it on github). How do I do that?

    • While not really a question related to Rider, let’s see if we can help out here :-)

      GitHub has some excellent docs on getting started with GitHub pages over at https://guides.github.com/features/pages/. This is a relatively easy way of getting started with building a (static) website.

      Beyond GitHub Pages, JetBrains has the tools to create your own web application, whether in .NET (using Rider or ReSharper), or using PhpStorm, WebStorm, PyCharm, etc.

  2. Lou says:

    I’m currently evaluating whether Rider can support what I’m looking to do here – .NET dev on Linux for Unity plugins. Apparently I need to use .NET 3.5 in my particular case, but coming from many years of Java (where this kind of thing can be done with a simple download and unzip) it’s not completely clear how to start building a class library using the 3.5 framework. I was able to specify 3.5 easily enough with monodevelop, but “netstandard2.0” and “net40” seem to be the closest available versions. You mention Rider supports 3.5 if it’s installed on the system… meaning at the OS level? (Part of this confusion may just be unfamiliarity with .NET version/framework differences..)

    • Matt Ellis says:

      Yes, Rider should be able to work fine in this situation, and has a project template specifically for creating class libraries that work with Unity, by including a reference to UnityEngine.dll.

      When you click New Solution on the welcome screen, in the .NET section (not the .NET Core) section, there’s a Unity Class Library template that includes a path to the UnityEngine.dll assembly. It also has a drop down to select the target framework version, you can use this to select “.NET Framework v3.5”.

      You can do the same with a normal .NET Class Library – simply select .NET Framework v3.5 in the new project dialog.

      Note that on Linux (and Mac) you’ll need to have Mono installed, so that Rider has the appropriate msbuild, compilers and reference assemblies available.

      • Lou says:

        Ah! I had been using just “Class Library” under .NET core. I needed to select Class Library under the .NET category (I hadn’t even noticed “Class Library” was there twice) or the Unity Class Library! Dang, now I might end up buying a license…

  3. Alex says:

    Does Rider support displaying dropbox menu for custom template? (like ‘Type’ param in this image https://d3nmt5vlzunoa1.cloudfront.net/dotnet/files/2017/12/search-templates-preview.png)

  4. Jindrich says:

    Hi, I’ve created a simple custom template following these instructions:
    https://docs.microsoft.com/en-us/dotnet/core/tutorials/create-custom-template

    then I installed it from disk (not using NuGet) with:
    dotnet -new -i pathToTemplateFolderOnMyMachine

    the command succeeded and I could see my template among installed templates in the terminal. Then I run:
    dotnet new myTemplateName

    and it worked, the files were copied to the folder i was in.

    The problem is that I cannot see the template in Rider. Next I tried I adding the template using the “Install Template” button. I looked like everything was ok, path to the template was listed below the “Install Template” button but I still could not see the template in the menu on the left.

    Are there some additional requirements for the templates so that rider can show them? What am I missing?

    Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *