【问题标题】:Publish .cshtml views for RazorLight in .net core 3.0在 .net core 3.0 中发布 RazorLight 的 .cshtml 视图
【发布时间】:2020-04-23 19:29:11
【问题描述】:

我所有的代码都是open source。请随意浏览。我在 bug/fix-emails 分支上。

我正在尝试发布RazorLight 发送 HTML 电子邮件所需的一些 .cshtml 文件。 .cshtml 文件放在这里:

我已经引用了Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation 并且在我的.csproj 中我有:

<ItemGroup>
  <Content Update="EmailTemplates\*.cshtml">
    <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
  </Content>
</ItemGroup>

然而,当我发布时,我没有看到 EmailTemplates 文件夹,也没有看到 ForgotPassword.cshtmlRegistration.cshtml。我做错了什么?

【问题讨论】:

  • “但当我发布时,我没有看到 EmailTemplates 文件夹,也没有看到 ForgotPassword.cshtml 和 Registration.cshtml。” 你能分享一下结果的屏幕截图吗?我测试了您的项目并将其发布到 folderProfile 目标,OutputDirectory 中有 EmailTemplates 文件夹。
  • @XueliChen 这里是the output。抱歉耽搁了,我才看到你的回复!

标签: asp.net-core razor asp.net-core-mvc publish


【解决方案1】:

我遇到了类似的问题,这就是我在.csproj 中所做的以克服这个问题。 VS 将在发布前执行xcopy 命令,它将文件复制到out 文件夹中。然后这将一起发布到特定的发布文件夹。

<Target Name="PrePublishScript" BeforeTargets="PrepareForPublish">
    <Exec Command="xcopy &quot;$(ProjectDir)Templates&quot; &quot;$(PublishDir)Templates&quot; /S /F /I /R /Y" />
</Target>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-04-23
    • 1970-01-01
    • 1970-01-01
    • 2020-01-25
    • 2020-02-08
    • 1970-01-01
    相关资源
    最近更新 更多