Вопрос

I have some .cshtml templates I'm using to render to PDFs.

When I deploy to production they get precompiled and contain the text "This is a marker file generated by the precompilation tool, and should not be deleted!" Is there a way to tell ASP.NET not to precompile a particular subfolder? I thought maybe I could do this in web.config, but I can't find it.

Это было полезно?

Решение 2

I couldn't stop the views from being compiled, even by setting the build action to 'none' and turning on copy to output directory.

I ended up changing the extensions of my files to .prod, setting the content type as 'content', and setting them to open with the HTML editor in Visual Studio to get everything working the way I wanted.

Другие советы

I know this is 2 years old but recently I stumbled on the same problem, but since I needed the view for both MVC and e-mail I couldn't simply change the extension of the file.

Searching for solutions I found this documentation on aspnet_compiler and the -u options, that stands for Updatable, which keeps the original file intact after compilation.

In order to achieve the desired behavior I configured my publish profile as follow:

  • On Settings tab of Publish dialog expand the File Publish Options and check Precompile during publishing. enter image description here
  • Click the Configure link after the checkbox and check Allow precompiled site to be updatable enter image description here

Caution

Before jumping in this solution you should read carefully about the implications of this option. In the link I provided there is a Precompilation Decision Matrix to help on your decision.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top