Sdk: Areas/**/Views glob is not working in publishOptions/include in project.json

Created on 29 May 2016  路  13Comments  路  Source: dotnet/sdk

Steps to reproduce

Project structure:

Project root
|_ Areas
    |_ Area1
    |  |_ Views
    |      |_ Index.cshtml
    |_ Area2
       |_ Views
           |_ Index.cshtml
|_ wwwroot
|
...

project.json snippet:

"publishOptions": {
        "include": [
            "wwwroot",
            "Views",
            "Areas/**/Views",
            "web.config"
        ]
    }

Publish to IIS with Visual Studio 2015 with ASP.net Core RC2 and Web Deploy 3.6 (with server rc2 components installed).

Expected behavior

Areas/Area1/Views/Index.cshtml and Areas/Area2/Views/Index.cshtml should be published.

Actual behavior

No "Areas" folder is published.

Environment data

dotnet --info output:

.NET Command Line Tools (1.0.0-preview1-002702)

Product Information:
 Version:     1.0.0-preview1-002702
 Commit Sha:  6cde21225e

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.10586
 OS Platform: Windows
 RID:         win10-x64

I tested the glob pattern in python's glob module and it produces the expected result:
[ 'Areas\Area1\Views', 'Areas\Area2\Views' ] (with the working directory set to the xproj directory).

Am I missing something or is this a bug ?

Most helpful comment

Temporary fix as stated here is to add

"Areas/ * /.cshtml"

All 13 comments

I have experienced with same issue in visual studio 2015 and asp.net core rc2 when using web deploy with azure app services.

Temporary fix as stated here is to add

"Areas/ * /.cshtml"

@TrplM maybe more like Areas/**/Views/**/*.cshtml to support folder/controllers

This still repros for me as of:

.NET Command Line Tools (1.0.0-preview2-003121)

Product Information:
 Version:            1.0.0-preview2-003121
 Commit SHA-1 hash:  1e9d529bc5

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.10586
 OS Platform: Windows
 RID:         win10-x64

I had this problem today. Worked around it by changing "Areas/**/Views" to "Areas/**/Views/**/*.cshtml" in my project.json.

does anyone have a repro they can share? I'd like to make sure this is fixed in Preview3.

Sure,

I just created a new blank ASP.Net project, added an area (see last commit), and then tried to build+publish. The area is missing in the outputs.

Then added the patch described above (Areas/**/*.cshtml) and the area views appeared in the publish outputs.

Created a blank repository with it: artiomchi/WebApplicationAreaPublishTest

@artiomchi I've used your project.json on a smaller stock app (from the templates), added the Area from your repo and the glob from the issue. Then I issued dotnet publish -o pub and the area's views were copied to the pub output folder.

This means that the move to MSBuild has mitigated the issue. I will close it as such. If you do see this repro with the latest CLI tooling and/or you think this closure was in error, please reopen. Thanks!

I use Asp.net Core 2 and after publish VIEWS folder is no. I written publishOption in project.json and appsettings.json but it not help. I tested the Asp.net Core 1.1 project and after publish the VIEWS folder is always. (by Default). What do I need to do to make the Views folder public?

@vvgrad asp.net core 2 doesn't really work with project.json. Upgrade to VS 2017 / csproj (dotnet migrate) to get a supported version of the tooling.

That aside, the default for publish now in 2.0 is precompiling the vies to an additional .dll file and not publishing the .cshtml files.

Clarify please!
I Can't In Asp.net Core 2 include VIEWS Folder (for IIS Published) ?
I need include a folder VIEWS so that I can edit some an views files after published.

Yes that is the default, since the files aren't usually edited after development and startup times can be improved by precompilation.

You can disable this by putting the following snipped in your .csproj file:

  <PropertyGroup>
    <TargetFramework>netcoreapp2.0</TargetFramework>
    <MvcRazorCompileOnPublish>false</MvcRazorCompileOnPublish>
  </PropertyGroup>

dasMulli , Thank you so much!!!!
I didn't know about "MvcRazorCompileOnPublish" parametr.

Was this page helpful?
0 / 5 - 0 ratings