有没有办法从“预编译"选项中排除某些 .cshtm 文件或整个文件夹,以便 .cshtml 文件可以在 MVC 之外使用? [英] Is there a way to exclude certain .cshtm files, or an entire folder, from the 'precompile' option so that the .cshtml files can be used outside MVC?

查看:23
本文介绍了有没有办法从“预编译"选项中排除某些 .cshtm 文件或整个文件夹,以便 .cshtml 文件可以在 MVC 之外使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 HangfirePostal 从页面周期异步发送电子邮件(在 MVC 5 应用程序中).创建电子邮件的线程使用 RazorEngine 项目.

I am using Hangfire and Postal to send emails asyncronously from the page cycle (in an MVC 5 app). The thread which creates the email uses the RazorEngine project.

Visual Studio 2013 (express) 项目设置为发布期间预编译",允许预编译站点可更新"设置为 false.这具有显着的优势,因为我使用的是共享 Web 主机,并且无法更改应用程序池回收时间(20 分钟).如果网站在 20 分钟内没有被点击,该网站对请求的响应速度会显着加快.

The visual studio 2013 (express) project is set to 'Pre-compile During Publish' with 'allow precompile site to be updatable' set to false. This has significant advantages, as I am using a shared web host, and have no ability to alter the app pool recycle time (which is 20 mins). The site responds to requests significantly faster if the site has not been hit for 20 mins.

但是,已发布的站点具有用于电子邮件模板的自动生成标记".cshtml 文件(即使复制到输出目录设置为始终复制),并且(非 MVC)线程仅在以下情况下才会正确生成电子邮件每次发布后,我都会将 Visual Studio 项目中的 Views/Email 文件夹手动复制到已发布文件夹中.

However, the published site has "auto generated marker" .cshtml files for the email templates (even when copy to output directory is set to copy always), and the (non-MVC) thread will only generate the emails correctly if I copy the Views/Email folder from the visual studio project into the published folder manually after every publish.

有没有办法从预编译"选项中排除某些 .cshtm 文件或整个文件夹,以便 .cshtml 文件可以在 MVC 之外使用.谢谢.

Is there a way to exclude certain .cshtm files, or an entire folder, from the 'precompile' option so that the .cshtml files can be used outside MVC. Thank you.

推荐答案

[项目] > [属性] > [发布配置文件] > [your.pubxml]

[Project] > [Properties] > [PublishProfiles] > [your.pubxml]

<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
 ...
    <ExcludeFilesFromDeployment>
      somefolder\otherfolder\*.cshtml;folder2\*.cshtml;foo.cshtml
    </ExcludeFilesFromDeployment>
    <ExludeFoldersFromDeployment>
      foo\bar;Views
    </ExludeFoldersFromDeployment>
  </PropertyGroup>
</Project>

不知道这是否有帮助,但是您可以通过发布配置文件 (.pubxml) 排除文件/文件夹吗?更多信息:https://msdn.microsoft.com/en-us/library/ee942158(v=vs.110).aspx

No idea if this helps but can you exclude the files/folders via your publish profile (.pubxml) ? More info: https://msdn.microsoft.com/en-us/library/ee942158(v=vs.110).aspx

这篇关于有没有办法从“预编译"选项中排除某些 .cshtm 文件或整个文件夹,以便 .cshtml 文件可以在 MVC 之外使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆