Using Visual Studio 2012 I am able to edit Razor TBBs by opening and saving them back via webdav. The problem is that if there is a Razor syntax error, it seems like they are saved OK, but actually they are not - there is no feedback of the error that you would normally get when saving them using the Tridion GUI. Is it possible to get Visual Studio to show this error, or (even better) get Visual Studio do the compilation/error checking that Tridion does before saving?
I developed Visual Studio 2010 Extension (might be working in 2012) for synchronization Visual Studio *.cshtml files with Tridion TBBs via CoreService
The main idea how to make razor mediator files editable is next:
Add next web.config to 'fake' ASP.NET MVC application
<?xml version="1.0" encoding="utf-8"?> <configuration> <system.web> <compilation debug="true" targetFramework="4.0"> <assemblies> <add assembly="Tridion.Extensions.Mediators.Razor, Version=18.104.22.168, Culture=neutral, PublicKeyToken=5eeceedb34d9dfd7" /> <add assembly="Tridion.Common, Version=22.214.171.124, Culture=neutral, PublicKeyToken=349a39f202fa9b53" /> <add assembly="Tridion.ContentManager.Templating, Version=126.96.36.1996, Culture=neutral, PublicKeyToken=360aac4d3354074b" /> </assemblies> </compilation> </system.web> </configuration>
Add declaration to the top of razor file
Please read document for details https://drive.google.com/folderview?id=0B6hZ-cambftrV25ZLU5QTnJWSmM&usp=sharing#list
I like the idea of capturing the error in Visual Studio. One possible approach might be to execute the relevant mediator code in a build step or from a VS extension. I'd start with the Compile method at https://code.google.com/p/razor-mediator-4-tridion/source/browse/trunk/Tridion.Extensions.Mediators.RazorMediator/Tridion.Extensions.Mediators.RazorMediator/Engine/Compiler.cs
You may be able to get this to work directly, but if not, I think it would be a great enhancement for the mediator if we could get it to support this approach. It's probably much easier if you are developing on the machine where Tridion is installed. To support off-the-box work, we might need some sort of service.
Here is in my blog explained how to debug Razor Mediator .cshtml files in Visual Studio.