3

In project we have implemented custom view engine inheriting from RazorViewEngine to solve custom views locations and logic behind choosing them.

The problem is that if I enable bulding views on project build then I get erros from views that @model doesn't exists and HtmlHelpers also doesn't.

What is more intellisense on views doesn't work. I tried to fix it by adding/editing web.config in views folder, but it doesn't work.

I think problem is that compiler on build try to use default Razor view engine which cannot resolve namespaces in custom views locations.

Project is working and views works etc, but compiling views on build doesn't, because it throws errors like @model doesn't found etc.

I have this in project csproj:

...
<MvcBuildViews>true</MvcBuildViews>
...

Any idea what needs to be done to make it working again?

Mogget
  • 75
  • 5
  • Put the verbosity of msbuild to diagnostic and study the task that uses MvcBuildViews parameter to try to undestand if it accepts additional parameters. Otherwise you can collect the running task code, inspect it and create a custom one to run. – Luca Mazzanti Sep 13 '17 at 14:47
  • Thanks for good idea! I tried this and solved few problems, but i hit the wall with views that doesn't recognice model and mvc methods extensions. (In running app it is working). I tried to fix it by editing views web.config but without any success. Any idea what to do about it? – Mogget Sep 14 '17 at 10:26
  • sorry i don't understand you rquestion – Luca Mazzanti Sep 14 '17 at 10:33
  • Compiler during building views doesn't find definition for MVC stuff like model, Html helpers etc. I tried to fix it by playing with web.config that is in views folder, but this doesn't work. My intellisense also doesn't recognize these methods, but these views work in running applications, so code if valid. – Mogget Sep 14 '17 at 10:39
  • ok sorry I can't help you I cannot try this example, i put a comment only to help you during msbuild time task. – Luca Mazzanti Sep 14 '17 at 10:45

0 Answers0