gpt4 book ai didi

c# - ASP.NET Core RC2 区域未发布

转载 作者:可可西里 更新时间:2023-11-01 07:44:41 26 4
gpt4 key购买 nike

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

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

enter image description here

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

enter image description here

我是漏掉了一步还是什么?

最佳答案

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

例如:

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

更新

如果您想确保不包含您的 Controller 和其他 .cs 文件,您可以使用 publishOptionsexclude 属性将其列入黑名单,如下所示:

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

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

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

注意

小心使用像 **.cshtml 这样的通配符,因为它们会包含所有子目录中的所有文件,包括 bin 目录。如果您的 bin 文件夹中有来自先前构建的任何 View ,它们将在新构建输出中再次复制,直到路径变得太长。

关于c# - ASP.NET Core RC2 区域未发布,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37326068/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com