Improve your development build process with these Kentico 12 page and form builder files

Written by Ilesh Mistry
March 19th 2019

5 mins read

For Kentico, the move to MVC has been a positive one, setting the EMS product onto a clear roadmap and enabling developers to leverage new technologies to deliver even greater user experiences. But the shift to MVC wasn’t smooth for everyone – for editors and content administrators they were essentially abandoning a world of flexible widgets and embeddable forms that they had grown accustomed to.

The content management experience has always been a point of pride for Kentico and they have worked tirelessly to update the MVC editing experience, bringing back these popular features in a new MVC ready format to support editors and content administrators.
Kentico 12 - Driving innovation and results for both marketers and developers

There’s lots of amazing new features in Kentico 12 (you can read more in this release from Karol Jarkovsky).

This is all great news, but it does mean that as Kentico developers we need to ensure that best practices are in place for these new features to avoid detracting from the inherent positives of the MVC approach. Specifically, I want to focus on the Page Builder and Form Builder features that have been introduced and what we need to consider within our development processes.

Website vs Web Application approach

Before we get into the specifics of the Page Builder and Form Builder features, let’s first consider the project approach. For those unaware, there are two approaches in the build process for Kentico sites – the Web Application and the Website. I mention this because the route you choose will affect the way you package and build the files.

For Web Application projects, you will place all required files from the solution and anything that must be built on the server into a concealed package file. This concealed package file would then be used on the server.

For a traditional website approach, you will have to package all the files from the solution and build them on the server they require to run on.

There are pros and cons to both approaches and we could spend an entire blog post debating which is the most appropriate. (But then Kentico legend Bryan Soltis explored this very topic in a great post which describes the differences between the two: Kentico Web App vs Website: Which One Is Best?)

For this article, we’re going to focus on the Web Application route. It’s been our typical approach (not always, but most of the time!) since adopting Kentico MVC.

The problem with resource strings

The introduction of these new features means new files that are required to ensure the features run correctly. With both the Page Builder and the Form Builder, Kentico has included files that the Admin application requires. In the previous section, I’ve talked about packaging these files up but now you need to apply them.

The Kentico 12 documentation covers off the configuration of both the Page Builder and Form Builder so make sure you get up to speed with these first before moving ahead. However, there are nuances in these new features which you will come across in practical development. The key element I want to focus on is resource strings.

With the configuration out of the way, the first thing you will notice is that something isn’t quite right with the Page Builder sections and widgets and the Form Builder sections and field properties. Specifically, resource strings have not been converted and therefore have not come through.
Kentico 12 Form Builder with missing resource stringsFor local development, this won’t cause you much of a problem but as you move into other environments, you will soon have problems with how it renders.

The key thing to note here is that the location of the resource strings does not sit in the Admin solution. The Page Builder and Form Builder resource strings sit in the MVC application.
Kentico 12 App_Data locationSo why is this happening? The reason is simple. Our build process ignores most of the App_Data section within the MVC application when building the project and deploying to the different environments - so the resource strings are not picked up.

Similarly, resource strings cannot be picked up if your MVC and Admin applications are hosted on separate virtual machines in Microsoft Azure - especially if you are not building a Website project.

The solution

For you to make sure the resource strings show up correctly within Kentico, it is important to set the files to be included in your solution for a Web Application project.

One way to do this is to follow the steps below:

  1. Open the FolderProfile.pubxml file in your MVC solution. You can find this by going to the Properties area and then to PublishProfiles.
    Kentico 12 - App_Data folder location of resource strings
  2. Set the exclude App_Data property to False and then make sure you save the file.
  3. Within the properties of each file you wish to include, you will need right click on it and then select the properties. Make sure you set the Build Action field to Content.
  4. If you have a .gitignore file for the repository and this is set to ignore contents within the App_Data folder, adjust it to allow the files within that specific folder and ignore the rest as you would have had it set.
  5. Finally, then you would need to publish your project to ensure that the above configurations have taken place.

Conclusion

The practicalities of Kentico MVC development will always introduce challenges – big and small – and there are always smart and sensible ways to handle these challenges without compromising the effectiveness of your solution. Hopefully this guide to handling resource strings has been useful and demonstrates the approach to take.

If you have questions on MVC development and want to know more about best practices, you can get in touch with a member of our development team here.