简体   繁体   English

ASP.NET Core 2-文件未发布

[英]Asp.net core 2 - Files are not published

EDIT 编辑

For info, I'm developping on macOS using VS Code 有关信息,我正在使用VS Code在macOS上进行开发

I'm trying to include files in my publish process ( Currently cshtml that represents my email templates ). 我正在尝试在发布过程中包含文件(目前,代表我的电子邮件模板的cshtml )。

I follow this thread on github but seems that their solutions don't work for me. 我在github上关注了这个线程 ,但似乎他们的解决方案对我不起作用。

Here my csproj to add an unique cshtml file : 在这里我的csproj添加一个独特的cshtml文件:

  <Target Name="PrepublishScript" BeforeTargets="PrepareForPublish">
    <ItemGroup>
      <EmailFile Include="$(ProjectDir)/EmailTemplates/OrderCompleteEmail.cshtml" />
    </ItemGroup>
    <Copy SourceFiles="@(EmailFile)" DestinationFolder="$(PublishDir)" SkipUnchangedFiles="false" />
  </Target>

Your solution was almost correct, you have to use AfterTargets="Publish" : 您的解决方案几乎是正确的,您必须使用AfterTargets="Publish"

<Target Name="CopyCustomContentOnPublish" AfterTargets="Publish">
  <ItemGroup>
    <EmailFile Include="EmailTemplates/OrderCompleteEmail.cshtml" />
  </ItemGroup>
  <Copy SourceFiles="@(EmailFile)" DestinationFolder="$(PublishDir)" />
</Target>

You can also copy all your email templates in a single Target to the same folder like: 您还可以将单个目标中的所有电子邮件模板复制到同一文件夹,例如:

  <Target Name="CopyCustomContentOnPublish" AfterTargets="Publish">
    <ItemGroup>
      <EmailTemplates Include="EmailTemplates\*.cshtml" />
    </ItemGroup>
    <Copy SourceFiles="@(EmailTemplates)" DestinationFolder="$(PublishDir)%(EmailTemplates.RelativeDir)" />
  </Target>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM