Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

What are the current guidelines on view precompilation (MvcBuildViews etc.)? #3993

Closed
DavidR91 opened this issue Jan 26, 2016 · 10 comments
Closed

Comments

@DavidR91
Copy link

There are a multitude of blogs and posts mentioning RazorPreCompileModule (example) but this does not appear to work in RC1

Other issues related to precompilation mention the use of the Publish options for 'compile source' etc. but this only seems to affect controller code etc. and not views

What is the current approach to precompiling views in RC1? (e.g. at the point of publish)

EDIT:
To clarify, I'm referring to MVC 6.0 RC1 -final against DNX 4.5.1

@danroth27
Copy link
Member

We are removing precompilation support in RC2 (#3917) due to issues with getting it to work on the new .NET CLI. We will revisit precompilation in a future release.

@DavidR91
Copy link
Author

That makes sense

Just to confirm - is that a future release, as in, future release after final of v6 (e.g. 6.1), or a future RC? (I'm assuming the former, but I'm not clear on how many RCs etc. are expected or the anticipated ship date for 6 etc.)

@nicholaj05
Copy link

I have been trying to use portable areas using .NET MVC 6 RC1 whereby each area exists in a separate class library project using precompiled views and have not been able to get it to work
I have been using the method .RazorPreCompileModule in combination .AddControllersAsServices and .AddPrecompiledRazorViews in startup.cs to achieve precompiled views and was wondering whether there is in fact a way to get portable areas working on RC1 using this method? To clarify – I can route to and display pre-compiled views in the main MVC 6 Project, but not to views in the Class Library dlls.
The controller actions are invoked correctly, but the views in the dlls are always not found.

I have been getting the error message “An unhandled exception occurred while processing the request. ArgumentNullException: Value cannot be null, Parameter name: type”. I was wondering whether this is a known issue or whether I have gone wrong somewhere in my code?

Just to echo the previous posters question – if support for pre-compiled views is being removed from RC2 – when will it be re-introduced?
This is a show stopper for our project, as we need to implement portable areas. Are we better off using MVC 5 & RazerGenerator?

@pranavkm
Copy link
Contributor

@nicholaj05, embedding the views should be an alternative for now - https://github.com/aspnet/Mvc/tree/dev/samples/EmbeddedViewSample.Web, https://github.com/johnnyoshika/mvc6-view-components. Another work item that discusses something similar - #3750

@pranavkm
Copy link
Contributor

I have been getting the error message “An unhandled exception occurred while processing the request. ArgumentNullException: Value cannot be null, Parameter name: type”.

Could you include a stack trace with this or provide a minimal sample that causes the exception.

@danroth27
Copy link
Member

Just to confirm - is that a future release, as in, future release after final of v6 (e.g. 6.1), or a future RC?

A future release after final. Not a future RC.

@nicholaj05
Copy link

Previously the RazorGenerator team said they had no plans to produce a version for MVC6, due to the fact that MVC 6 supports precompile views.
In view of the fact that Precompiled Views have been removed from MVC 6 Final, does that mean the RazorGenerator team will now release a version for MVC 6?

@ToddThomson
Copy link

Ouch. Removed features after RC is painful. I'll take a look at EmbeddedFileProvider.

@DmitrySikorsky
Copy link

But what about strongly typed views? Let's say I have some assembly A that have controller, view and view model class defined (and view build as resource). I add this A as application part to the main app and get runtime compilation error that view model class is not defined (because there are no link to assembly A in the project.json). Is there any way to add assemblies to the Razor views compilation process now? Thanks!

@pranavkm
Copy link
Contributor

pranavkm commented May 19, 2016

@DmitrySikorsky - we're working on using ApplicationParts to make this work by default. See #4498. For RC2, you can use CompilationCallback on RazorViewEngineOptions. See #4087 (comment)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants