sdk icon indicating copy to clipboard operation
sdk copied to clipboard

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

Open rwasef1830 opened this issue 10 years ago • 13 comments

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 ?

rwasef1830 avatar May 29 '16 15:05 rwasef1830

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

ikybs avatar Jun 07 '16 09:06 ikybs

Temporary fix as stated here is to add

"Areas/ * /.cshtml"

TrplM avatar Jun 07 '16 13:06 TrplM

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

sadjadbp avatar Jul 15 '16 02:07 sadjadbp

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

rynowak avatar Jul 15 '16 15:07 rynowak

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

damccull avatar Oct 04 '16 20:10 damccull

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

TheRealPiotrP avatar Nov 10 '16 08:11 TheRealPiotrP

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 avatar Nov 10 '16 08:11 artiomchi

@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!

thesmithee avatar Jan 13 '17 01:01 thesmithee

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 avatar Oct 08 '17 09:10 vvgrad

@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.

dasMulli avatar Oct 08 '17 09:10 dasMulli

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.

vvgrad avatar Oct 08 '17 19:10 vvgrad

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 avatar Oct 08 '17 20:10 dasMulli

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

vvgrad avatar Oct 09 '17 05:10 vvgrad