【问题标题】:Publish extra files in Core 3 - before I could use publishOptions (project.json)在 Core 3 中发布额外文件 - 在我可以使用 publishOptions (project.json) 之前
【发布时间】:2020-03-19 16:53:15
【问题描述】:

我正在尝试在我的项目中实现“功能文件夹/切片”...

https://docs.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"
  ]
},

但 core 3 中不存在 project.json 和 publishOptions。

如何在 Core 3 中解决这个问题?

【问题讨论】:

    标签: asp.net-core


    【解决方案1】:

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

    Is it possible to deploy an uncompiled ASP.NET Razor Pages website?

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

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

    在属性 -> PublishProfiles -> YourProfile.pubxml 中,添加...

    <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>
    

    就是这样:)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-12-28
      • 2017-04-13
      • 1970-01-01
      • 1970-01-01
      • 2012-08-14
      • 2020-01-01
      • 1970-01-01
      相关资源
      最近更新 更多