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.
Areas
folder BUT it also publishes theControllers
folder inside an area with.cs
files! That's not wanted! – Isodimorphism