Code hinting in templates

Code hinting – like Visual Studio’s IntelliSense – is context-aware code completion feature which speeds up the process of coding by e.g. reducing typos and showing the programmer which namespaces and methods are available in a given context.

As such, it is almost indispensable if you’re working with e.g. ViewModels or the API and will save you from countless of hours of browsing the API documentation and muttering curses to yourself.

In this guide we will cover the following:

  • Creating a new project in Visual Studio
  • Installing the packages necessary to use code hinting
  • Adding an existing Files folder to the project
  • Creating the solution in IIS Manager

In this guide we presuppose that you’re following our recommended setup with a separate /Files folder for each solution and shared applications, but the setup should be easily transferable to other types of setups. We also assume that you’re developing locally and will deploy templates and other solution-specific files using the Deployment tool.

In this article we will use Visual Studio and therefore IntelliSense – and while you may be able to use other IDEs with NuGet support we haven’t tested this internally.

  1. Open Visual Studio and create new VS project – select the ASP.NET Web Application template (Figure 2.1)
  1. Fill in the project details – name, location, and solution name - and make sure the target framework is .NET Framework 4.7.2 (Figure 2.2).
  1. Click Create and select the Empty project template (Figure 2.3) – then click Create again
  1. After the project has been crated you must install the packages you will use in your templates, chiefly Dynamicweb.Ecommerce – right-click the project and select Manage NuGet Packages (Figure 3.1)
  1. Check Include prerelease then open the Settings (Figure 3.2)
  1. Add the Dynamicweb production feed (Figure 3.3)
  1. Browse for the Dynamicweb.Ecommerce package and install it with Dependency behaviour set to lowest (Figure 4.1)
  1. Due to a bug in NuGet you may get an error – Unable to resolve dependency ‘RazorEngine.Roslyn’. If you do open the Package Manager Console (Tools > NuGet Package Manager > Package Manager Console) and install Dynamicweb.Ecommerce using the command Install-Package Dynamicweb.Ecommerce -Version X.X.XX –IncludePrerelease where X.X.XX is the latest stable released version. Go get coffee.
  2. If this is a Rapido solution, also include the Dynamicweb.Rapido.dll file from Nuget.

After the packages have been installed it’s time to add a /Files-folder to the project. This could be a clean barebones Files folder as created by the Dynamicweb Installer, a Rapido folder, or a copy of a /Files folder from an existing solution.

The procedure is the same, however:

  1. Copy the /Files-folder into the project folder – you can right-click the project and click Open folder in file explorer if you’re not sure where the project folder is
  2. In Visual Studio click Show all files in the solution explorer toolbar, then right-click the /Files/Templates folder and then press Include in project (Figure 5.1). Include other folders where you have content you want to work with, e.g. the System folder or the Files/Integration folder.

This basically completes the whole add code-hinting part of the article – if you open any of the templates you just added to the project you should now benefit from IntelliSense.

Of course, you typically also want to create a website the solution in IIS Manager – so that you can see your template changes in a browser before deploying them.

Please do the following:

You can now visit the URL in a browser and see any changes you make to the templates live.