首页 文章

ASP.NET Core RC2区域未发布

提问于
浏览
15

所以我刚刚更新了我的应用程序以使用ASP.NET Core RC2 . 我使用Visual Studio发布它并注意到我的区域未发布:

此快照来自 src\MyProject\bin\Release\PublishOutput

enter image description here

这是我的区域,在Visual Studio中名为 Admin

enter image description here

我错过了一步还是什么?

2 回答

  • 0

    您需要配置 project.jsonpublishOptions 部分以包含默认模板中未包含的 Areas 文件夹:

    例如:

    "publishOptions": {
      "include": [
        "wwwroot",
        "Views",
        "appsettings.json",
        "web.config",
        "Areas"
      ],
      "exclude": [ "bin" ]
    }
    

    Update

    如果要确保不包含控制器和其他.cs文件,可以使用 publishOptionsexclude 属性进行黑名单,如下所示:

    "publishOptions": {
      "include": [ "wwwroot", "Views", "appsettings.json", "web.config", "Areas" ],
      "exclude": [ "**.user", "**.vspscc", "**.cs", "bin" ]
    }
    

    如果您更喜欢更严格的安全性,您可以简单地将.cshtml文件列入白名单,而不是包括整个区域文件夹,如下所示:

    "publishOptions": {
      "include": [ "wwwroot", "**.cshtml", "appsettings.json", "web.config" ],
      "exclude": [ "bin" ]
    }
    

    Note

    小心使用像 **.cshtml 这样的通配符,因为它们将包括所有子目录中的所有文件,包括 bin 目录 . 如果您在之前版本的 bin 文件夹中有任何视图,则它们将在新版本输出中再次复制,直到路径变得太长 .

  • 21

    添加区域将复制包括.cs文件在内的所有内容 .

    所以应该在发布选项下添加 "Areas/**/Views/**/*.cshtml""Areas/ * /.cshtml" 而不是仅仅 "Areas"

相关问题