ASP.NET Core RC2区域未发布 [英] ASP.NET Core RC2 Area not published
问题描述
所以我刚刚更新了我的应用程序以使用ASP.NET Core RC2。我使用Visual Studio发布了该文件,并注意到我的区域未发布:
So I just updated my app to use ASP.NET Core RC2. I published it using Visual Studio and noticed that my Area is not published:
此快照来自 src\MyProject\bin\Release OutputPublishOutput
:
这是我的区域,在Visual Studio中名为 Admin
:
And here is my Area, named Admin
in Visual Studio:
我错过了一步还是什么?
Am I missing an step or what?
推荐答案
您需要配置 project.json
的 publishOptions
部分,以包含 Areas
文件夹,该文件夹不包含在默认模板中:
You need to configure your publishOptions
section of project.json
to include the Areas
folder which is not included in the default template:
ex:
"publishOptions": {
"include": [
"wwwroot",
"Views",
"appsettings.json",
"web.config",
"Areas"
],
"exclude": [ "bin" ]
}
更新
如果您要确保不包括控制器和其他.cs文件,可以使用 publishOptions
exclude 属性将其列入黑名单>像这样:
If you want to ensure that your controllers and other .cs files are not included, you can blacklist with the exclude
property of publishOptions
like so:
"publishOptions": {
"include": [ "wwwroot", "Views", "appsettings.json", "web.config", "Areas" ],
"exclude": [ "**.user", "**.vspscc", "**.cs", "bin" ]
}
如果您希望使用更具限制性的安全性,则可以将.cshtml文件简单地列入白名单包括整个区域文件夹,如下所示:
If you prefer more restrictive security, you can simply whitelist .cshtml files instead of including the entire Areas folder like so:
"publishOptions": {
"include": [ "wwwroot", "**.cshtml", "appsettings.json", "web.config" ],
"exclude": [ "bin" ]
}
注意
请谨慎使用通配符,例如 **。cshtml
,因为它们将包含所有子目录中的所有文件,包括 bin
目录。如果您以前的版本在 bin
文件夹中有任何视图,它们将在新的版本输出中再次复制,直到路径变得太长。
Be careful using wildcards like **.cshtml
as they will include all files in all subdirectories, including the bin
directory. If you have any views in your bin
folder from a previous build, they will be duplicated again inside the new build output until the path becomes too long.
这篇关于ASP.NET Core RC2区域未发布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!