问题
EDIT
For info, I'm developping on macOS using VS Code
I'm trying to include files in my publish process ( Currently cshtml
that represents my email templates ).
I follow this thread on github but seems that their solutions don't work for me.
Here my csproj to add an unique cshtml
file :
<Target Name="PrepublishScript" BeforeTargets="PrepareForPublish">
<ItemGroup>
<EmailFile Include="$(ProjectDir)/EmailTemplates/OrderCompleteEmail.cshtml" />
</ItemGroup>
<Copy SourceFiles="@(EmailFile)" DestinationFolder="$(PublishDir)" SkipUnchangedFiles="false" />
</Target>
回答1:
Your solution was almost correct, you have to use 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>
来源:https://stackoverflow.com/questions/49444457/asp-net-core-2-files-are-not-published