This project is read-only.

Razor View Library Issues

Nov 2, 2012 at 4:22 PM

I downloaded the example to use the views as an external library and works like a charm but when I try to replicate the example on my project it doesn't work. Do I need to do something else besides:

1. Downloading and installing the nuget pkg (on my views library project which was creating the mvc application template).
2. Setting the CustomTool to RazorGenerator on the view files.
3. Referencing on my main site the external views library project.

Its worth mentioning that I'm using ASP.NET MVC 4 in this scenario and that the class files that must be generated for each view aren't being generated either.

Nov 2, 2012 at 5:52 PM

I just updated to MVC4 and reran the generator on all views (Redo-RazorGenerator command in the NuGet console). It seems to work fine.

Not sure what's different about yours, but at least we got them one step closer.

Nov 2, 2012 at 6:00 PM
Edited Nov 2, 2012 at 6:00 PM

Out of curiosity, was the Views Library a Class Library project? We do some project detection to identify the kind of code generator (mvc \ webpages \ templates etc) and Class Libraries have been a bit erratic to deal with at times. 

Nov 2, 2012 at 8:25 PM

@pranavkm No the views are in a referenced mvc app project.

Nov 2, 2012 at 8:55 PM

@davidebbo @pranavkm I uploaded my non-working example here: in case you wanna give it a look.

I believe I have everything like you described it on the documentation. I saw that in previous versions I had to install an extension to the VS but I believe that in the current version is not necessary.

Nov 2, 2012 at 9:14 PM

Yes, you still need to install the VS extension. See Installation Instructions on

Nov 6, 2012 at 4:25 PM

Hi guys, I've installed the VS extension and have made some progress. Now my project generates the cs for each of my Views. I added a reference to the Views Library project and I'm getting the generic error for non-existing views:

The view 'Index' or its master was not found or no view engine supports the searched locations. The following locations were searched:

Am I still missing something?

Nov 6, 2012 at 4:52 PM

Do you have the RazorGenerator.Mvc package installed?

Nov 6, 2012 at 5:28 PM

Yes. But only for the external views library project.

Nov 8, 2012 at 4:09 PM

Ok I finally was able to make this work on a new project. There were some quirks with the layout references but at least views were compiled and on an external project.

When trying to replicate everything on an existing project I keep getting this error: The custom tool 'RazorGenerator' failed. The method or operation is not implemented.

The nuget pkg and the vsix extension are installed. If I create projects from scratch everything works just fine.

Nov 8, 2012 at 4:29 PM

Could you start Visual Studio with /log switch ( and check if the log contains any specifics about the generator?

Nov 8, 2012 at 4:59 PM

Hi @pranavkm. There's no trace of the RazorGenerator keyword on the log.

Nov 8, 2012 at 5:41 PM

VS 2012 uses randomized names for extension locations which does make it a bit tricky to locate a specific extension. Do you see any entries with the type "Error" or "Warning" in it? 

Nov 8, 2012 at 7:20 PM

I have an Error and a Warning. But none of them has to do with the RazorGenerator. Here's the ActivityLog:

Nov 8, 2012 at 7:28 PM

So there is  NuGet error about PowerShell 3. Might be unrelated, but can you try uninstalling NuGet to eliminate that possibility?

Nov 8, 2012 at 7:39 PM
Edited Nov 8, 2012 at 7:40 PM

Well, the code generation does work on the other project. So I doubt if that the powershell error could be the cause for  this. That said, this is running off on a tangent, but do you think I could get you to try the MsBuild task instead?

It *might* be a bit simpler to set up \ and a bit more forthcoming with the exceptions.

Nov 8, 2012 at 8:07 PM

So I removed Nuget and everything worked just fine.

But I'm using EF Code First with migrations for instance and I need the Package Manager Console in order to run my migration scripts from within VS. So for convenience I followed the msbuild approach but the RazorGenerator.msbuild file doesn't seem to exist. I updated my csproj file and imported the RazorGenerator.targets file but it doesn't seem to do the trick.

I'd like to thank you both for your interest in helping me.

Nov 8, 2012 at 8:13 PM

Fixed the documentation to point to the right file name. 

a) Did you add the property to your project file. I would put it right in the first PropertyGroup that appears in the document (before the Import)

b) Are there files generated under obj\CodeGen? The msbuild task does not add files to your project.

Nov 8, 2012 at 8:16 PM

Never mind I found the files. Didn't read the end of the documentation and found the generated files on the obj\CodeGen directory. How do I add this compiled files to my other project now?

Nov 8, 2012 at 8:40 PM

Simple reference this project. As long as you have RazorGenerator.Mvc installed in your Mvc app, things should light up. 

Nov 8, 2012 at 8:58 PM

I have the reference. Installed the nuget pkg in both just in case. And now the routing engine cannot find my views :-(