在使用publishOptions(project.json)之前,在Core 3中发布额外的文件



我正试图在我的项目中实现"功能文件夹/切片"。。。

https://learn.microsoft.com/en-us/archive/msdn-magazine/2016/september/asp-net-core-feature-slices-for-asp-net-core-mvc

在上面的链接中,他们写道:

To support publishing correctly, you’ll also need to update project.json’s publishOptions to include the Features folder:
JavaScript
Copy
"publishOptions": {
"include": [
"wwwroot",
"Views",
"Areas/**/*.cshtml",
"Features/**/*.cshtml",
"appsettings.json",
"web.config"
]
},

但是project.json和publishOptions在Core 3中并不存在。

如何在Core 3中解决此问题?

这篇文章解决了我的问题。。。

是否可以部署未编译的ASP.NET Razor Pages网站?

添加对Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation的引用。

添加启动services.AddRazorPages().AddRazorRuntimeCompilation();

在"属性"->"发布配置文件"->"YourProfile.publxml"中,添加。。。

<ItemGroup>
<ViewFiles Include="$(ProjectDir)Features***.cshtml" />
<JsFiles Include="$(ProjectDir)Features***.js" />
</ItemGroup>
<Target Name="CopyViewFilesAfterPublish" AfterTargets="Publish">
<Copy SourceFiles="@(ViewFiles)" DestinationFolder="$(PublishDir)Features%(RecursiveDir)" />
<Copy SourceFiles="@(JsFiles)" DestinationFolder="$(PublishDir)Features%(RecursiveDir)" />
</Target>

就这样:(

最新更新