ASP.NET Core RC2 Area not published

老子叫甜甜 提交于 2019-12-05 11:13:19

问题


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:

This snapshot is from src\MyProject\bin\Release\PublishOutput:

And here is my Area, named Admin in Visual Studio:

Am I missing an step or what?


回答1:


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" ]
}

Update

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" ]
}

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" ]
}

Note

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.




回答2:


Adding Areas will copy everything including the .cs files.

so should add "Areas/**/Views/**/*.cshtml" and "Areas/ * /.cshtml" under publish options instead of only "Areas"



来源:https://stackoverflow.com/questions/37326068/asp-net-core-rc2-area-not-published

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!