Visual Studio Razor Extension

Main functionality

Possibility to work with Tridion content in Microsoft Visual Studio:

  • Edit razor code for Razor Mediator TBBs
  • Synchronize *.cshtml files with Tridion
  • Create Tridion Component Templates and Page Templates from Visual Studio automatically
  • Synchronize Visual Studio binaries (*.css, *.js, *.jpg, *.png, etc.) with Tridion multimedia components

Prerequisites

  • Microsoft Visual Studio 2010 / 2012 /2013 installed on local machine
  • Tridion CM 2013 or 2013 SP1 with Razor Mediator 1.3.x installed on a local or remote machine

Installation

  1. Run TridionVSRazorExtensionInstaller_v2.2.msi
    i1
    Pass all steps.

  2. Create new or open existing ASP.NET MVC application in Visual Studio. You will notice new extension in Tools menu
    i2

  3. You can use dialog window for adjusting VS/TCM mapping and to run VS/TCM synchronization
    i3

  4. You can use context menu on item or folder in Solution Explorer to run VS/TCM synchronization
    i4

Mapping

* All mapping info is stored in TridionRazorMapping.xml file in project root.

TCM mapping

Select folders on TCM side. Remember about BluePrint, select folder in top-level publication.
i5
Every Tridion folder must have one of next roles:

  • PageLayoutContainer. Folder that contains Razor Mediator TBBs for page layouts.
  • ComponentLayoutContainer. Folder that contains Razor Mediator TBBs for components.
  • PageTemplateContainer. Folder that contains Page Templates.
  • ComponentTemplateContainer. Folder that contains Component Templates.
  • MultimediaComponentContainer. Folder that contains Multimedia Components.
  • Other. No synchronization actions defined for this folder.

By default synchronization works only in VS -> TCM direction. To run two-way synchronization, please use Two-way checkbox.

* TCM -> VS synchronization is more time-consuming, since TCM folders are scanned for new items.

Visual Studio mapping

Select folders from Visual Studio MVC project.
i6

Use double-clicks to edit existing folder settings or button �Add� to add new folder.

i7

In this dialog you can change folder and file settings

  1. Role. Select project folder role:
    • PageLayout. Folder contains *.cshtml files for page templates.
    • ComponentLayout. Folder contains *.cshtml files for component templates.
    • Binary. Folder contains binaries (*.jpg, *.png, *.js, *.css, etc)
    • Other. Folder action is not defined.
    If files of different purpose are mixed in the same folder on file system you can map this folder twice and select only files of specific type. All checked files inherit role from parent folder.
  2. Template. Whether to create page or component template after razor file was synchronized to Razor TBB. (Only PageLayout and ComponentLayout roles)
  3. Tridion Folder. If you have more than one Tridion folder you can select to which folder synchronize.
  4. Template Format. Piece of XML like next
    i8
    It is used to create Compound Templates (page or component) from Razor TBB. All checked files inherit role from parent folder.
  5. Schema Names. List of schema names to link to Component Compound Template on creating.

Synchronization

You can run synchronization in three ways:

  1. Dialog window � �Run Synchronization�.
    Runs synchronization for all mapped Tridion and project folders.
    • Item exists only in project. User will be prompted to enter name of new Tridion item select publication
      i9
    • Item exists only in Tridion (two-way must be enable for Tridion folders(s))
      User will be prompted to enter name of new project item and select project folder to place it.
      i10
    • Item exists in both project and Tridion. Application compare dates and suggests user which version to use.

    * It is important to select proper time zone to have a proper time comparison

    User can make decision which version to use

    * You won�t lose your previous changes. If you synchronize Tridion item from project then new Tridion item version will be created, and you will be able to roll it back. If your project item will be overwritten by Tridion item then you can use your version control system to roll it back (please check in project before run synchronization)

  2. Context menu on file(s)
    i12
    This kind of synchronization will synchronize only selected items.
    * Note that context synchronization will be run for all mappings!
    * TCM -> VS synchronization is not possible to be run from context menu.
    If item is not mapped to any folder you will get message and synchronization will be canceled.
    i13

  3. Context menu on folder
    i14

Work with Razor Mediator files

To provide Visual Studio compatibility for Razor Mediator files next conditions should be followed:

  1. Next web.config file must be present in parent project folder
    i15

  2. Add declaration to the top of razor file

    @inheritsTridion.Extensions.Mediators.Razor.TridionRazorTemplate

  3. Use intellisense
    i16

    If Razor Mediator file was crated from Tridion TBB by synchronizations then project changes 1 - 3 are made automatically by the application.
    If file is created in Visual Studio please remember about requirements 1 - 3.

The project is available on Google code as an open source project where you can report issues and download the latest source code and installer.


Developer
:    Mark Vlasenko
Company
License agreement
Download package
Tags
:    Visual Studio,  Razor Mediator
Version
:   2.2
Source
:   Yes

About the Author
Mark Vlasenko
Consultant

Mark is a consultant at SDL CMT division. He joined SDL in January 2013. Mark has experience in web development over 10 years.

SDL CMT division