Túlio Nogueira
Túlio Nogueira

Reputation: 51

Exclude folders on publish project using "dnu publish"

How can I exclude folders from wwwroot using "dnu publish" command.

Example: in my project exists many folders

I need exclude wwwroot/lib and wwwroot/source.

I´m using clr 1.0.0-beta7-12302

Upvotes: 5

Views: 1529

Answers (4)

SliverNinja - MSFT
SliverNinja - MSFT

Reputation: 31641

MS dropped support for bower_components and node_modules exclusion in .NET Core 1.0 RTM. The best I was able to achieve was just to exclude the /src folders so the publish size could be reduced.

Project.json (Excluding Bower Components SRC files)

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

Upvotes: 1

ForrestB
ForrestB

Reputation: 21

I too was looking for a way to exclude the wwwroot/lib directory from being published and I came across this post from Scott Hanselman. In the post he shows how to change the storage location of bower components (ex. from wwwroot/lib to /bower_components).

For me this removed the wwwroot/lib directory, so these libraries are no longer published. I just thought I would throw this here in case someone may be able to use it.

Upvotes: 1

Troy Dai
Troy Dai

Reputation: 2111

The wwwroot folder is treated differently. It is called a webroot. The content in this folder doesn't go through globbing during publish (see here). It is recommended that source code and output are put out of the webroot.

Do you have scenario that you have to store source codes and binaries in this folder?

Upvotes: 3

BenM
BenM

Reputation: 553

Within the Project.json file it looks like you can specify which files you would like to exclude when publishing using the publishExclude property in the sources section. https://github.com/aspnet/Home/wiki/Project.json-file#sources

Upvotes: 2

Related Questions